0

When a simple-escape-sequence like '\n' is evaluated, what would be the result? Is it ASCII 10? How I can show ASCII 10 as a character? Isn't it '\n' again? I am confused! Can someone please help me with the issue?

2
Contributors
1
Reply
19
Views
4 Years
Discussion Span
Last Post by deceptikon
1

When a simple-escape-sequence like '\n' is evaluated, what would be the result?

It's evaluated as the platform-dependent character for a newline. For example, on Linux '\n' will be evaluated as LF (ASCII 10) while on Windows it'll be evaluated as CRLF (ASCII 13 + ASCII 10). But it's totally irrelevant unless you're bypassing the standard I/O framework because those translations will be done under the hood. Your program will never see anything except '\n'.

How I can show ASCII 10 as a character?

Just print the value 10 in character context:

printf("ASCII 10: '%c'\n", 10);

Edited by deceptikon

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.