Jump to content
  • Advertisement
Sign in to follow this  
games_mylife10

how can i end a while loop ??

This topic is 4748 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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; }

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
look at the break; statement.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
combining his name, his location and

using std::cout;
using std::cin;
etc.

and

char text[1000];

I'd say he's kidding...

Share this post


Link to post
Share on other sites
Quote:
Original post by games_mylife10
i want to (end-of-file) lol!!!

I'd say he's 11 years old.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!