From: "Jesper Lund" Newsgroups: comp.os.msdos.djgpp References: <01c14445$8cc5f3e0$bc8684d5 AT feta> <01c14449$4c5c3fe0$bc8684d5 AT feta> Subject: Re: what's the equivalent of for gpp ? Lines: 26 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Message-ID: Date: Sun, 23 Sep 2001 20:09:49 +0200 NNTP-Posting-Host: 213.237.1.23 X-Complaints-To: news-abuse AT wol DOT dk X-Trace: news010.worldonline.dk 1001268590 213.237.1.23 (Sun, 23 Sep 2001 20:09:50 MET DST) NNTP-Posting-Date: Sun, 23 Sep 2001 20:09:50 MET DST Organization: Customer of Tiscali A/S (World Online) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Gwen wrote in message news:01c14449$4c5c3fe0$bc8684d5 AT feta... > > I'm experiencing some problems with stdio.h and I want to use iostream.h, > In fact, I think I'll have the same problems with iostream.h : I can't > recognize when I read a file when there is a carriage return. > I tried this : > > int c=getc(f); > while (c!=13) { addch(c); } > > It displays all the characteres of my files, with the cariage return but it > doesn't break the loop and it reachs the end of file and loops forever. > I would suggest that that you post the minimal code example which reproduces your problem (and can be compiled). The above two lines of code would indeed loop forever as the integer variable c is never modified (unless addch is a C++ function which takes an int& as argument). If you want to read characters from an ascii files until the next carriage return, you can use the function getline() in either C or C++.