Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send ctrl+z in C

Tags:

c

character

I'm working with Arduino.

I want to send Ctrl+z after a string in C. I tried truncating ^Z but that didn't work. So how to do that ?

like image 452
omerjerk Avatar asked Apr 21 '13 15:04

omerjerk


1 Answers

Ctrl+Z = 26 = '\032' = '\x1A'. Either of the backslash escape sequences can be written in a string literal (but be careful with the hex escape as if it is followed by a digit or A-F or a-f, that will also be counted as part of the hex escape, which is not what you want).

However, if you are simulating terminal input on a Windows machine (so you want the character to be treated as an EOF indication), you need to think again. That isn't how it works.

It may or may not do what you want with Arduino, either; in part, it depends on what you think it is going to do. It also depends on whether the input string will be treated as if it came from a terminal.

like image 134
Jonathan Leffler Avatar answered Oct 07 '22 22:10

Jonathan Leffler