From: "A. Sinan Unur" Newsgroups: comp.os.msdos.djgpp Subject: Re: what's the equivalent of for gpp ? Date: 23 Sep 2001 18:18:16 GMT Organization: Cornell University Lines: 53 Sender: asu1 AT cornell DOT invalid (on slip-32-102-40-235.ny.us.prserv.net) Message-ID: References: <01c14445$8cc5f3e0$bc8684d5 AT feta> <01c14449$4c5c3fe0$bc8684d5 AT feta> NNTP-Posting-Host: slip-32-102-40-235.ny.us.prserv.net X-Trace: news01.cit.cornell.edu 1001269096 14359 32.102.40.235 (23 Sep 2001 18:18:16 GMT) X-Complaints-To: usenet AT news01 DOT cit DOT cornell DOT edu NNTP-Posting-Date: 23 Sep 2001 18:18:16 GMT User-Agent: Xnews/4.06.22 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Gwen" wrote in 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); } how is this supposed to work? you are only reading one character out of the file. try something like this: #include #include int main(int argc, char *argv[]) { int c; FILE *fin; fin = fopen(argv[1], "rt"); if( fin == NULL ) { perror(argv[1]); exit(EXIT_FAILURE); } while( (c = getc(fin)) != EOF) if( c != '\n' ) putc(c, stdout); return 0; } > 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. it is impossobile to know what error you made without seeing the code that you actually used. hth. sinan. -- -------------------------------- A. Sinan Unur http://www.unur.com/