从stdin发送任意字节到fgets

我正在使用fgets(user_input,input_len,stdin)提示用户提供的字符串。 我怎样才能将hex \ x04表示的字节发送给程序?

你可以做

 $ echo -n -e '\x04' | your-program 

注意:在POSIX echo只允许八进制值。

如果您可以将所需的字节输入文件,则可以运行

 your-program < file