6 Replies - 841 Views - Last Post: 27 January 2013 - 08:27 PM Rate Topic: -----

#1 recheej  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 26-December 12

Program does not respond to input (Beginner)

Posted 22 January 2013 - 09:45 AM

Hello peeps. I'm learning C in my programming class and I'm a beginner. I'm trying to do a simple program where the user enters a number, then the program spits it back out. But for some reason when I enter the number and hit enter, nothing happens.

Here's my code:


int main(void){
	int i, k;

	printf("Enter some number: \n");
	scanf("%d", &i);
	printf("%d\n", i);
	printf("Enter some other number: \n");
	scanf("%d", &k);
	printf("%d", k);
	return 0;
}




[UPDATE]

Let me clarify a bit more. Instead of printing out the first output, the program skips to waiting for the first input. When I enter the input, nothing happens.

This post has been edited by recheej: 22 January 2013 - 09:47 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Program does not respond to input (Beginner)

#2 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 762
  • View blog
  • Posts: 2,218
  • Joined: 20-March 10

Re: Program does not respond to input (Beginner)

Posted 22 January 2013 - 10:33 AM

There is nothing wrong with the above program

Which IDE/Compiler are you using ?


You might have an issue there...

Snoopy.
Was This Post Helpful? 0
  • +
  • -

#3 recheej  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 26-December 12

Re: Program does not respond to input (Beginner)

Posted 22 January 2013 - 11:10 AM

I'm using eclipse with CDT plugin.
Was This Post Helpful? 0
  • +
  • -

#4 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 762
  • View blog
  • Posts: 2,218
  • Joined: 20-March 10

Re: Program does not respond to input (Beginner)

Posted 22 January 2013 - 01:57 PM

Hi,

Its a bug with the 64 bit version of eclipse a workaround is to install the 32 bit version.

If you type your two numbers then it will display in the CDT Console bit weird I know.

Snoopy.
Was This Post Helpful? 0
  • +
  • -

#5 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1306
  • View blog
  • Posts: 4,495
  • Joined: 19-February 09

Re: Program does not respond to input (Beginner)

Posted 22 January 2013 - 03:20 PM

You could try adding a space before the format string parameter to remove whitespace.

08    scanf("%d", &k);
      /* change to */
      scanf(" %d", &k);


Was This Post Helpful? 0
  • +
  • -

#6 recheej  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 26-December 12

Re: Program does not respond to input (Beginner)

Posted 27 January 2013 - 07:02 PM

I tried both of these; did not work.
Was This Post Helpful? 0
  • +
  • -

#7 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1306
  • View blog
  • Posts: 4,495
  • Joined: 19-February 09

Re: Program does not respond to input (Beginner)

Posted 27 January 2013 - 08:27 PM

Are you using Windows?

Eclipse console does not show output on Windows
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1