在创建subversion存储库时,会将许多挂钩模板文件放入文件系统中。在检查示例precommit钩子时,它详细说明了钩子是通过参数传递的信息执行的,看起来也是通过STDIN传递的。
# ... Subversion runs this hook by invoking a program
# (script, executable, binary, etc.) named 'pre-commit' (for which
# this file is a template), with the following ordered arguments:
#
# [1] REPOS-PATH (the path to this repository)
# [2] TXN-NAME (the name of the txn about to be committed)
#
# [STDIN] LOCK-TOKENS ** the lock tokens are passed via STDIN.捕获参数是微不足道的,但是程序如何捕获STDIN?下面的代码片段在int main(...)中运行没能收集到任何东西。
char buffer[1024];
std::cin >> buffer;
buffer[1023] = '\0';我做错了什么?
发布于 2010-11-29 22:55:59
逐行阅读输入的最简单方法是以下范例:
std::string line;
while(getline(line, std::cin)) {
// Do something with `line`.
}它也是安全、可靠和相对有效的。不要在不必要的情况下摆弄字符缓冲区。
https://stackoverflow.com/questions/4304843
复制相似问题