0
首先感到抱歉,如果这是一个愚蠢的问题(当然是),但我真的很陌生,在Unix中使用Syscall。 我试图用“写”在文件上写东西;它正确地创建文件,但没有写上它,这是代码:成功的写并不会在文件上写任何东西
int main(void) {
int fd;
char *string = "Test";
if(fd=open("home/user/test.txt", O_WRONLY | O_APPEND | O_CREAT)==-1){
perror("Open failed");
}
printf("%d\n", strlen(string));
printf("Wrote %d byte on the file", write(fd,string,strlen(string)));
close(fd);
return 0;
}
我的问题在哪里? 谢谢
什么写回来?你在第二个printf中获得了什么? – Jay