当前位置: 技术问答>linux和unix
linux下向利用系统调用创建的文件写内容失败??
来源: 互联网 发布时间:2016-08-12
本文导语: #include #include #include using namespace std; int main() { char filePath[20]; int Openread; int Openwrite; cout filePath; Openread = open(filePath, O_RDONLY); while ( Openread == -1) { cout filePath; Openread = open(filePath, O_RDONLY); } cout fil...
#include
#include
#include
using namespace std;
int main()
{
char filePath[20];
int Openread;
int Openwrite;
cout filePath;
Openread = open(filePath, O_RDONLY);
while ( Openread == -1)
{
cout filePath;
Openread = open(filePath, O_RDONLY);
}
cout filePath;
Openwrite = open(filePath, O_WRONLY);
if( Openwrite == -1)
{
cout r;
if(r == 'Y')
{
Openwrite = open(filePath, O_CREAT, S_IRUSR|S_IWUSR);//如果不存在则创建
cout