#include<stdio.h>
void main()
{
FILE *fptr;
if((fptr=fopen("test.txt","w"))!=NULL)
{
fprintf(fptr,"this is a test file.");
fclose(fptr);
}
else
printf("error");
}
void main()
{
FILE *fptr;
if((fptr=fopen("test.txt","w"))!=NULL)
{
fprintf(fptr,"this is a test file.");
fclose(fptr);
}
else
printf("error");
}
本文介绍如何使用C语言中的fopen、fprintf和fclose函数来创建文本文件并将其内容写入指定文件中。

6万+

被折叠的 条评论
为什么被折叠?



