问题
I'm prompting for a user supplied string using fgets(user_input, input_len, stdin). How can I send, for instance, the byte represented by hex \x04 to the program?
回答1:
You can do
$ echo -n -e '\x04' | your-program
NOTE: On POSIX echo
only octal values are allowed.
回答2:
If you can get the bytes you want into a file, you can run
your-program < file
来源:https://stackoverflow.com/questions/36185321/sending-arbitrary-bytes-to-fgets-from-stdin