Subject: B20: fgets() again. (Enter isn't enter!)
From: [email-masked] (Paul Wilson)

6 Dec 1998 14:41:14 -0800
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: [email-masked]

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
"[email-masked]" with one line of text: "help".