Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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

Status
Not open for further replies.

hithesh123

Full Member level 6
Joined
Nov 21, 2009
Messages
324
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Location
lax
Activity points
3,548
How to send enter or Carriage return using printf on serial port?
 

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

Brian.
 

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");
 

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

Not really. My frist C program was just

Code:
printf("Hello world");
 

Followup question -

how to send ctrl+z using printf?
 

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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top