I have been working on a problem that is driving me crazy. The fgets now returns null strings instead of the strings in the file it is reading. I extracted the code to the simplest snippet (below). I have changed my gcc from 3.4 to 4.1.1, reloaded all libraries I can identify in cygwin. fgets does work on stdin. My environment is Windows Server 2003 running Cygwin with gcc compiler. The only thing I can say that changed was the installation of gdb 6.5 (debugger) which I loaded to troubleshoot another problem (which I found and fixed). So, what libraries should I be looking at?
Your help will be greatly appreciated.
Here's sample code:
printf("enter a string to test the fgets function on stdin: ");
printf("stdin string is: %s\n",ch);
/* open the config file*/
conf_file = fopen(temp_str, "r");
if (conf_file == NULL)
printf("fatal error - failed to open file: %s", temp_str);
printf("end of file encountered\n");
printf("file: %s has been opened\n", temp_str);
while ( fgets(read_string, strlen(read_string), conf_file) != NULL)
printf("read config fail error\n");
printf("read_string is: %s\n", read_string);