程序D1053.c的功能是:在指定的文件中存入一串从键盘输入的字符(@表示结束输入),文件名通过命令行指定:
改/*********Found************/下的内容#include<stdio.h>#include<stdlib.h>intmain(intargc,c...
改/*********Found************/下的内容
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE *fp;
char ch;
/*********Found************/
if (argc != ______________)
{
printf("the number of arguments not correct\n\n");
printf("Usage: 可执行文件 filename\n");
exit(1);
}
/*********Found************/
if ((fp = fopen(______________, "w")) == NULL)
{
printf("can not open this file\n");
exit(2);
}
for( ; (ch=getchar()) != '@' ; )
{
/*********Found************/
fputc(______________);
}
fclose(fp);
return 0;
} 展开
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE *fp;
char ch;
/*********Found************/
if (argc != ______________)
{
printf("the number of arguments not correct\n\n");
printf("Usage: 可执行文件 filename\n");
exit(1);
}
/*********Found************/
if ((fp = fopen(______________, "w")) == NULL)
{
printf("can not open this file\n");
exit(2);
}
for( ; (ch=getchar()) != '@' ; )
{
/*********Found************/
fputc(______________);
}
fclose(fp);
return 0;
} 展开
1个回答
展开全部
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE *fp;
char ch;
/*********Found************/
if (argc != 2)
{
printf("the number of arguments not correct\n\n");
printf("Usage: 可执行文件 filename\n");
exit(1);
}
/*********Found************/
if ((fp = fopen(argv[1], "w")) == NULL)
{
printf("can not open this file\n");
exit(2);
}
for( ; (ch=getchar()) != '@' ; )
{
/*********Found************/
fputc(ch, fp);
}
fclose(fp);
return 0;
}
#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE *fp;
char ch;
/*********Found************/
if (argc != 2)
{
printf("the number of arguments not correct\n\n");
printf("Usage: 可执行文件 filename\n");
exit(1);
}
/*********Found************/
if ((fp = fopen(argv[1], "w")) == NULL)
{
printf("can not open this file\n");
exit(2);
}
for( ; (ch=getchar()) != '@' ; )
{
/*********Found************/
fputc(ch, fp);
}
fclose(fp);
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询