Reputation: 5784
int main()
{
string line;
char buff[10];
for(int i=0; i<10;i++)
{
cin.get(buff[i]);
cout.put(buff[i]);
if(i==10)
{
ofstream file;
file.open("TEXT",ios::out);
for (i=0 ; i<10 ;i++)
file << buff[i] << endl;
file.close();
}
}
}
this code is not flushing the data from array to file and even file is also not created...
Upvotes: 1
Views: 356
Reputation: 363497
No, because inside your loop, i<10
, so your conditional is never executed. Put the flushing code after the loop.
Upvotes: 3