Results 1 to 4 of 4
I'm a C++ and Java programmer and I'm learning C currently from an ebook. I just switch to Ubuntu from Windows. I used Ubuntu a little but never programmed in ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 09-14-2010 #1Just Joined!
- Join Date
- Apr 2010
- Posts
- 7
Programmer needs help programming in Ubuntu!
I'm a C++ and Java programmer and I'm learning C currently from an ebook. I just switch to Ubuntu from Windows. I used Ubuntu a little but never programmed in Ubuntu before. I am doing an exercise in the book and what it does is gets the keyboard input and then prints it on the screen. It uses a while loop to get the characters until it reaches that EOF but when I run it in the terminal, I can't end the program. Its probably easy to fix but I'm not sure what to do.
He is the code
Code:#include <stdio.h> /* copy input to output; 1st version */ main() { int c; int quit; quit = 0; while((c = getchar()) != EOF) { putchar(c); } }
- 09-14-2010 #2Linux User
- Join Date
- Jan 2007
- Location
- cleveland
- Posts
- 468
works fine for me
2 comments:
1. do you need the int quit?
2. end the program by giving an EOF=ctrl-dthe sun is new every day (heraclitus)
- 09-14-2010 #3Linux Newbie
- Join Date
- Apr 2007
- Posts
- 119
ctrl-d is the EOF in a terminal.
- 09-14-2010 #4Just Joined!
- Join Date
- Apr 2010
- Posts
- 7
Ok I didn't know EOF is ctrl-d. Also the quit was in there because I was testing something. Thanks!!!


Reply With Quote
