在我大学的基础 Linux 编程课程中,我们使用 fcntl.h 和 unistd.h 使用 C++ 字符串,我得到以下信息:
statusOfFunction = write(fileDescriptor, input.c_str(), input.length());
这条线有效。我创建了一个文件,其中包含输入字符串的内容。但是,为什么这些行都不起作用:
statusOfFunction = read(fileDescriptor, reading.c_str(), 10);
Error: No matching function call to "read"
statusOfFunction = read(fileDescriptor, reading, 10);
Error: No matching function call to "read"
statusOfFunction = read(fileDescriptor, &reading, 10);
No error throws up, but does not get executed
statusOfFunction = read(fileDescriptor, &reading.c_str(), 10);
Error: No matching function call to "read"
https://www.dropbox.com/s/lnw208uo3xurqxf/Basic%20Unix%20Operations%20on%20Text%20Files.cpp?dl=0
这是程序,供您参考。谢谢!:)