|
From: Reid T. <Rei...@at...> - 2003-09-29 20:14:10
|
as info - I was running the program via the "compile and run" button on=20 the gui, rather than via a command line. reid > -----Original Message----- > From: Per Westermark [mailto:pw...@ia...]=20 > Sent: Monday, September 29, 2003 2:42 PM > To: vasanthsena x > Cc: Reid Thompson; dev...@li... > Subject: RE: [Dev-C++] Newbie Question. >=20 >=20 > It is a bit easier to count number of characters in the file=20 > if you move your nl++ inside the braces. >=20 > EOF works just as in all other C libraries. EOF is defined as=20 > -1 and that is the return value of getchar() after last=20 > character has been read. >=20 > For windows: > type myfile | my_eof_program >=20 > For Unix: > cat myfile | ./my_eof_program >=20 > should work. At least my terminals stays open if I run the=20 > program directly and enters text and end it with Ctrl-D.=20 > However, if I press Ctrl-D a second time, i.e. when I'm on=20 > the command line, I will loose my window. >=20 > /Per W >=20 > On Mon, 29 Sep 2003, vasanthsena x wrote: >=20 > > Hi Reid, > > > > EOF =3D=3D Ctrl-d. > > > > when I do that my window closes..Also why should I > > include <stdlib.h>? > > > > I ran your program too.It doesnt work either... > > > > Thanks, > > > > S. > > --- Reid Thompson <Rei...@at...> wrote: > > > #include <stdio.h> > > > #include <stdlib.h> > > > > > > main() > > > { > > > int c,nl=3D0; > > > > > > while (( c=3D getchar()) !=3D EOF) > > > { > > > } > > > ++nl; > > > printf("%d\n",nl); > > > system("PAUSE"); > > > return 0; > > > > > > > > > } > > > > > > else you will get number of characters entered > > > rather than number of > > > lines > > > > > > reid > > > > > > > > > > -----Original Message----- > > > > From: vasanthsena x [mailto:vas...@ya...] > > > > > > > Sent: Monday, September 29, 2003 12:40 PM > > > > To: dev...@li... > > > > Subject: [Dev-C++] Newbie Question. > > > > > > > > > > > > Can Someone tell me how getchar() and EOF work on > > > Dev > > > > C++. I have written the following program to count > > > # > > > > of lines. > > > > > > > > #include <stdio.h> > > > > main() > > > > { > > > > int c,nl=3D0; > > > > > > > > while (( c=3D getchar()) !=3D EOF) > > > > ++nl; > > > > printf("%d\n",nl); > > > > system("PAUSE"); > > > > return 0; > > > > > > > > > > > > } > > > > > > > > > > > > now before I get any output the screen > > > disappears.As > > > > you can see I have included system("PAUSE"); > > > > > > > > > > > > > > > > __________________________________ > > > > Do you Yahoo!? > > > > The New Yahoo! Shopping - with improved product > > > search > > > > http://shopping.yahoo.com > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > This sf.net email is sponsored by:ThinkGeek > > > > Welcome to geek heaven. > > > > http://thinkgeek.com/sf=20 > > > > _______________________________________________ > > > > Dev-cpp-users mailing list Dev...@li... > > > > TO UNSUBSCRIBE: > > > http://www23.brinkster.com/noicys/devcpp/ub.htm > > > > > > > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > > > __________________________________ > > Do you Yahoo!? > > The New Yahoo! Shopping - with improved product search=20 > > http://shopping.yahoo.com > > > > > > ------------------------------------------------------- > > This sf.net email is sponsored by:ThinkGeek > > Welcome to geek heaven. > > http://thinkgeek.com/sf=20 > > _______________________________________________ > > Dev-cpp-users mailing list Dev...@li... > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > >=20 >=20 |