填空题
请补充main 函数,该函数的功能是:先以只写方式打开文件“out99.dat”,再把字符串str中的字符保存到这个磁盘文件中。
注意:部分源程序给出如下。
请勿改动主函数main 和其他函数中的任何内容,仅在 main 函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include "stdio. h"
#include "conio.h"
#define N 80
main ()
FILE *fp;
int i=0;
char ch;
char str[N]="I’m a student!";
clrscr();
if ( (fp=fopen ( 【1】 ) ) ==NULL)
printf("cannot open out99. dat\n");
exit(0);
while (str[i])
ch=str[i];
【2】 ;
putchar(ch);
i++;
【3】 ;
【参考答案】
[1]“out99.dat”,“w” [2] fpnte (ch,fp) [3] fclose (fp)