This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

B20: fgets() again. (Enter isn't enter!)


I found that using ^J instead of enter gives the correct results.

Take this small bit of code:

#include <stdio.h>

char string[5];
char *fgets_ptr;

int main() {
	fgets_ptr = fgets(string, sizeof(string), stdin);
	string[strlen(string)-1] = '\0';
	printf("fgets_ptr is %s and string is %s\n", fgets_ptr, string);
	return(0);
}

Yeilds this when using "Enter" to execute it:

BASH.EXE-2.02$ ./fgetstest.exe

fgets_ptr is  and string is

But yeilds this when using ^J:

BASH.EXE-2.02$ ./fgetstest.exe^J
asd
fgets_ptr is asd and string is asd

Paul
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]