Quantcast
Channel: Active questions tagged carriage-return+c+linefeed - Stack Overflow
Viewing all articles
Browse latest Browse all 9

Accepting \r\n input C program

$
0
0

I would like to ask how can I accept \r\n without changing it to \\r\\n, with fgets.

I want the program to translate the \r\n to a newline character instead of printing it as a string.

Current code:

char buff[1024];printf("Msg for server: ");memset(buff, 0, sizeof(buff));fgets(buff, sizeof(buff), stdin);printf(buff);

Input:

test\r\ntest2

The output I want:

testtest2

My current output:

test\r\ntest2

Viewing all articles
Browse latest Browse all 9

Latest Images

Trending Articles





Latest Images