0

Is it possible to insert a byte 0xFF into a string input through scanf()?

I did try CTRL + ALT + u + FF, but that gives the yuml symbol (unicode FF). If I use GDB to see what the value of the byte inserted, I don't get 0xFF in that byte, and that symbol takes two bytes.

I also know that I can pipe a printf("\xFF") into my program as shown in this post.

However, I would like to see if I can input that manually.

I am using Linux, with console interface.

Community
  • 1
  • 1
Makketronix
  • 1,389
  • 1
  • 11
  • 31
  • 3
    This is not really a programming question, it's a question of how to input random data on your undisclosed operating environment. C and scanf don't have anything to do with it really. – Sami Kuhmonen Oct 10 '16 at 04:50
  • I guess the portable solution will be using pipe. However, other solution maybe doing it programmatically. User types ASCII chars, then when you encounter a *special character* (e.g. when user type `\FF`, `\01`, etc.), convert it to `int/hex` representation, e.g. when user type `abc\ff` then your application should interpret it as `a b c 0xFF`. – putu Oct 10 '16 at 05:32
  • If your terminal is expecting to work with Unicode (UTF-8), you can't really type `0xFF` as a byte as that byte cannot appear in valid UTF-8. In fact, the bytes 0xF5 through 0xFF cannot appear, and neither can 0xC0 or 0xC1. – Jonathan Leffler Oct 10 '16 at 06:06

0 Answers0