User forums > Help

How To Input EOF

(1/1)

zygote:
Hi there,

I just got started with learning C. I've having trouble with entering the EOF character to get the desired output. I've tried CTR+Z and CTR+C without any success. The window just closes immediately. The code I'm trying to run is:


--- Code: ---#include <stdio.h>

int main(void)
{
  int c;
  int inspace;

  inspace = 0;
  while((c = getchar()) != 48)
  {
    if(c == ' ')
    {
      if(inspace == 0)
      {
        inspace = 1;
        putchar(c);
      }
    }

   
    if(c != ' ')
    {
      inspace = 0;
      putchar(c);
    }
  }

  return 0;
}

--- End code ---

I'm running Windows 7 64 bit. I use F9 to run the code.

Could you please tell me how to run the above program correctly in Code Blocks? I need that window to stay open NOW!

Thanks for taking the time to read my issue. I appreciate it.

MortenMacFly:

--- Quote from: zygote on February 23, 2012, 01:34:31 pm ---Could you please tell me how to run the above program correctly in Code Blocks? I need that window to stay open NOW!

--- End quote ---
Did you try to run it in a console without IDE? Did you then enable to run it in a console from with C::B?

However, as you didn't state any C::B version information I can't tell you how to solve.

zygote:
I'm running version 1-8.c.

I don't really understand what you're talking about.  ???

I ran the code by pressing F9 (Build and Run).

I'm really sorry if these questions are downright elementary. I just got started with programming.  :-[

oBFusCATed:
There is no such version of codeblocks. So please be exact.
Also type cmd in the start menu's search box, press enter, then execute your program from there.
If you don't know how to handle the console, please search for a tutorial!

zygote:
The version is 10.05 rev 6283. Got it mixed up earlier.  ::)

Navigation

[0] Message Index

Go to full version