C语言用fopen()打不开文件
#include<stdio.h>#include<stdlib.h>#defineSIZE20intmain(void){intch;charname[SIZE];FI...
#include <stdio.h>
#include <stdlib.h>
#define SIZE 20
int main(void)
{
int ch;
char name[SIZE];
FILE * fp;
printf("Enter the file name: ");
scanf("%s", name);
if((fp = fopen(name, "r")) == NULL)
{
printf("Can't open %s\n", name);
exit(EXIT_FAILURE);
}
printf("Enter information: ");
while((ch = getchar) != EOF)
putc(ch, fp);
return 0;
} 展开
#include <stdlib.h>
#define SIZE 20
int main(void)
{
int ch;
char name[SIZE];
FILE * fp;
printf("Enter the file name: ");
scanf("%s", name);
if((fp = fopen(name, "r")) == NULL)
{
printf("Can't open %s\n", name);
exit(EXIT_FAILURE);
}
printf("Enter information: ");
while((ch = getchar) != EOF)
putc(ch, fp);
return 0;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询