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

为什么以下的写入文件的for语句可以无穷输入啊该怎么解决

2012-02-16 
为什么以下的写入文件的for语句可以无穷输入啊?同上,为什么可以没有止境的输入啊,是不是哪里错了?#include

为什么以下的写入文件的for语句可以无穷输入啊?
同上,为什么可以没有止境的输入啊,是不是哪里错了?

#include   <iostream.h>
#include   <fstream.h>
#include   <stdio.h>

ofstream     fp;
ifstream     ifp;

void   main()
{

char   fname[10],cline;
char   c[100];
cout < < "输入要建立的文件名以及保存路径: " < <endl;
cin> > fname;
cout < < "您要输入多少行内容? " < <endl;
cin> > cline;
cout < < "cline= " < <cline < <endl;
fp.open(fname,   ios::ate);
cout < < "请输入内容: " < <endl;
while(cline)
{
gets(c);
fp   < <   c;
fp   < <   endl;
cline--;
}
ifp.open(fname,   ios::nocreate);
cout < < "建立文件结束! " < <endl;
}


[解决办法]
char fname[10],cline;
===>
char fname[10];
int cline;

热点排行