C语言getchar详细用法
#include<stdio.h>#include<stdlib.h>intmain(void){FILE*fp;charch;if((fp=fopen("1.bat",...
# include <stdio.h>
# include <stdlib.h>
int main(void)
{
FILE * fp;
char ch;
if ((fp=fopen("1.bat","a+")) == NULL)
{
printf("1.bat文件打开错误");
exit(-1);
}
printf("请输入内容:");
ch=getchar();
while(ch!='#')
{
fputc(ch,fp);
putchar(ch);
ch=getchar(); //这个是什么意思
}
fclose(fp);
return 0;
} 展开
# include <stdlib.h>
int main(void)
{
FILE * fp;
char ch;
if ((fp=fopen("1.bat","a+")) == NULL)
{
printf("1.bat文件打开错误");
exit(-1);
}
printf("请输入内容:");
ch=getchar();
while(ch!='#')
{
fputc(ch,fp);
putchar(ch);
ch=getchar(); //这个是什么意思
}
fclose(fp);
return 0;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询