Plugins (1059)


Training and Consulting (44)



EPIC Poll

What is your favourite developer portal?

[ Results | Polls ]

Votes: 541
Comments: 0

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
superbee
5 Post subject: A problem with Eclipse CDT plugin  PostPosted: Jun 20, 2008 - 02:53 AM



Joined: Jun 20, 2008
Posts: 1

It seems there's something wrong when I use the "scanf" function.
Here's my code:

#include <stdio.h>
#include <stdlib.h>

int main(void) {
char name[20];
printf("Please enter your name:");
scanf("%s",name);
printf("%s says, Hello World",name);
EXIT_SUCCESS;
}

After building, I run the program. But the console doesn't display anything. The expecting result should be:

Please enter your name:aaa
aaa says, Hello World

But when I input "aaa" in the empty console,it displays:
Please enter your name:aaa says, Hello World

So the function "scanf" runs before the first "printf".
Anyone who can tell me how to resolve this problem?
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits