[51] How to send 'Enter' character using printf

Status
Not open for further replies.
Try '\n' or '\r' (backslash followed by 'n' or 'r'). You can also try sending character 0x0D which should do the same thing.

Brian.

The \n is for new line.
I will try the \r.

Sending char 0x0D is my last option. I'll have to write a serial port routing myself instead of using printf.
 

I though that people would learn this with their very first C program
Code:
printf("Hello world\r\n");
 

Hithesh123, the ctrl charaters and all punctuation characters are part of the ASCII character set. If you look at a copy you will see all charcters, including ones like CR have a number which you can use in their place. For example, for 'A' you can also use 0x41 or 65 decimal.

Brian.
 

Not really. My first C program was just printf("Hello world");
Kernighan-Ritchie The C programming language has this "first C programm"
Code:
printf("hello, world\n");
A single newline character is the usual line end signal in the Unix word, DOS/Windows has a carriage return + linfeed combination "\r\n".

how to send ctrl+z using printf?
According to the C standard, you would use an octal constant "\032" in the format string.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…