how can i end a while loop ??
Hi
I made this code, i want to (end-of-file) lol!!! i can't get out of this loop:
i mean i press ^z and it still keep asking me to enter more !!! how ??
my problem is when i ask to enter texts .. i can't stop it!
#include <iostream>
using std::cout;
using std::cin;
using std::ios;
using std::cerr;
using std::endl;
#include <fstream>
using std::ofstream;
#include <cstdlib>
int main()
{
ofstream outlinefile("Line.dat", ios::out);
if (!outlinefile) {
cerr <<"file could not be opened"<<endl;
exit(1);
}
cout << "Enter several lines of text: "<<endl
<< "Enter end-of-file to END input.\n?";
char text[1000];
while (cin.getline (text,1000)){
outlinefile <<text<<endl;
cout<< "?";
}
return 0;
}
oh, but i want from the user to enter several lines of texts !! when i used break; it got only one line of text!
thank you guys for helping me
thank you guys for helping me
combining his name, his location and
using std::cout;
using std::cin;
etc.
and
char text[1000];
I'd say he's kidding...
using std::cout;
using std::cin;
etc.
and
char text[1000];
I'd say he's kidding...
Isn't EOF ^d (CTRL-d) rather than ^z (CTRL-z)?
IIRC, CTRL-c is quit, CTRL-d is EOF, CTRL-z is background, CTRL-s is software flow control stop, CTRL-q is software flow control start...at least on 'nix. AFAIK it's just the normal ASCII set.
IIRC, CTRL-c is quit, CTRL-d is EOF, CTRL-z is background, CTRL-s is software flow control stop, CTRL-q is software flow control start...at least on 'nix. AFAIK it's just the normal ASCII set.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement