Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C文件操作问题_C - Fatal编程技术网

C文件操作问题

C文件操作问题,c,C,我想用*fd来写*fp以前打开过的文件 我怎么做 添加一些,这个问题的关键是使用另一个指针。请参见,*fd是不同的指针。希望我能说清楚。根据需要使用fwrite、fputc、fprintf或fputs 使用fputc,您可以放置一个字符: 使用fputs,您可以放置字符数组字符串: FILE *fp = fopen("filename", "w"); fputc('A', fp); // will put an 'A' (65) char to the file 使用fwrite,您还可以写入

我想用*fd来写*fp以前打开过的文件

我怎么做

添加一些,这个问题的关键是使用另一个指针。请参见,*fd是不同的指针。希望我能说清楚。

根据需要使用fwrite、fputc、fprintf或fputs

使用fputc,您可以放置一个字符:

使用fputs,您可以放置字符数组字符串:

FILE *fp = fopen("filename", "w");
fputc('A', fp); // will put an 'A' (65) char to the file
使用fwrite,您还可以写入二进制数据:

FILE *fp = fopen("filename", "w");
fputs("a string", fp); // will write "a string" to the file
使用fprintf,您可以写入格式化数据:

FILE *fp = fopen("filename", "wb");
int a = 31272;
fwrite(&a, sizeof(int), 1, fp);
// will write integer value 31272 to the file
根据需要使用fwrite、fputc、fprintf或fputs

使用fputc,您可以放置一个字符:

使用fputs,您可以放置字符数组字符串:

FILE *fp = fopen("filename", "w");
fputc('A', fp); // will put an 'A' (65) char to the file
使用fwrite,您还可以写入二进制数据:

FILE *fp = fopen("filename", "w");
fputs("a string", fp); // will write "a string" to the file
使用fprintf,您可以写入格式化数据:

FILE *fp = fopen("filename", "wb");
int a = 31272;
fwrite(&a, sizeof(int), 1, fp);
// will write integer value 31272 to the file
当然,如果我理解正确的话


当然,如果我理解正确的话。

你想做什么并不清楚。你想做什么也不清楚。