Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Problem With C/C++ "fgets" on eclipse, Help !(when i use fgets, the program doesn't debug until i write the fget value on the console.)
Problem With C/C++ "fgets" on eclipse, Help ! [message #1043257] Wed, 17 April 2013 13:28
programmer best is currently offline programmer best
Messages: 1
Registered: April 2013
Junior Member

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 ?
Previous Topic:how to debug libtool generated executable using CDT
Next Topic:CDT Install fails
Goto Forum:
  


Current Time: Wed Oct 01 14:23:48 GMT 2014

Powered by FUDForum. Page generated in 0.09682 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software