首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

一个文件输入有关问题,高手来看下

2012-02-23 
一个文件输入问题,高手来看下#include stdio.h#include stdlib.h#include conio.hvoid main(){FILE

一个文件输入问题,高手来看下
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
void main()
{
FILE *fp;
char str[11];
if((fp=fopen("11.txt","wt+"))==NULL)
{
printf("Cannot open file strike any key exit!");
getch();
exit(1);
}
printf("input a string \n");
fputs(str,fp);
fclose(fp);
}

我想不用SCANF()输入字符,请问有什么别的函数能坐倒吗?


[解决办法]

C/C++ code
#include  <stdio.h> #include  <stdlib.h> int main() {     FILE *fp;     char str[11];     if ((fp=fopen("11.txt","wt+"))==NULL)     {        printf("Cannot open file strike any key exit!");        getch();        exit(1);     }     printf("input a string \n");    gets(str); /*here*/    fputs(str,fp);     fclose(fp);    return 0;} 

热点排行