Problem With C/C++ "fgets" on eclipse, Help ! [message #1043257] |
Wed, 17 April 2013 09:28  |
Eclipse User |
|
|
|
Hi,
i have installed gcc & eclipse on windows.
when i use fgets, the program doesn't debug until i write the fget value on the console.
code:-
#include <stdio.h>
enum { max_string = 127 };
static char string[max_string + 1]="";
int main(int argc, char ** argv ){
printf("type string: ");
fgets(string, max_string, stdin);
printf("your string is %s\n", string);
return 0;
}
this is a simple c code to print "type string:", then fgets reads input to print it later.
so the right sequence of this program supposed to be like this:-
1. print "type string:" on console
2. fgets reads input and store it on "string" variable
3. print the "string" value
now the problem is the program runs on this sequence.
1. blank console page without printing anything and fgets reads input first
2. print everything written before fgets and after it
any help ?
|
|
|
|
Powered by
FUDForum. Page generated in 0.03742 seconds