Author Topic: How To Input EOF  (Read 12278 times)

Offline zygote

  • Single posting newcomer
  • *
  • Posts: 3
How To Input EOF
« on: February 23, 2012, 01:34:31 pm »
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;
}

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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: How To Input EOF
« Reply #1 on: February 23, 2012, 02:26:09 pm »
Could you please tell me how to run the above program correctly in Code Blocks? I need that window to stay open NOW!
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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline zygote

  • Single posting newcomer
  • *
  • Posts: 3
Re: How To Input EOF
« Reply #2 on: February 23, 2012, 03:36:22 pm »
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.  :-[

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How To Input EOF
« Reply #3 on: February 23, 2012, 03:50:51 pm »
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!
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline zygote

  • Single posting newcomer
  • *
  • Posts: 3
Re: How To Input EOF
« Reply #4 on: February 23, 2012, 04:25:06 pm »
The version is 10.05 rev 6283. Got it mixed up earlier.  ::)