Sending arbitrary bytes to fgets from stdin [closed]

这一生的挚爱 提交于 2019-12-13 08:34:11

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!