永发信息网

C语言格式读定文件

答案:1  悬赏:50  手机版
解决时间 2021-03-16 03:11
  • 提问者网友:动次大次蹦擦擦
  • 2021-03-15 12:10
C语言格式读定文件
最佳答案
  • 五星知识达人网友:时间的尘埃
  • 2021-03-15 13:02
#include 
#include 
#include 
int main()
{
char path[512], str[512];
FILE *file;
printf("please input filename:
");
scanf("%s", path);
file = fopen(path, "w");
if (file != NULL)
{
do
{
printf("
Inupt string:
");
scanf("%s", str);
fprintf(file, "%s
", str);
printf("
Continue:?");
scanf("%s", str);
} while (str[0] == 'y');
fclose(file);
file = fopen(path, "r");
putc('
', stdout);
while (fscanf(file, "%s", str) != EOF)
{
for (char *p = str; *p; p++)
{
if (isalpha(*p))
putc(toupper(*p), stdout);
else
putc(*p, stdout);
}
putc('
', stdout);
}
}
system("pause");
return 0;
}运行结果:

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯