Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    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

    #include <stdio.h>
    /* copy input to output; 1st version */
    	int c;
    	int quit;
    	quit = 0;
    	while((c = getchar()) != EOF)

  2. #2
    Linux User
    Join Date
    Jan 2007
    works fine for me

    1. do you need the int quit?
    2. end the program by giving an EOF=ctrl-d
    the sun is new every day (heraclitus)

  3. #3
    ctrl-d is the EOF in a terminal.

  4. $spacer_open
  5. #4
    Ok I didn't know EOF is ctrl-d. Also the quit was in there because I was testing something. Thanks!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts