一連の文字をバイナリ ファイルに挿入する必要があります。
そのために、fwrite を使用します。その後、 を入れたいと思い\0
ます。
どうすればいいのかわかりません。
const unsigned char *my_word; /*my_word has no \0 at the end*/
fwrite(my_word, my_word_length_in_bytes, 1, my_file);
助けていただけますか?
ありがとう。
以下を使用できます。
fputc(0, my_file);
バッファ my_word に +1 を割り当てる必要があります。
my_word[my_word_length_in_bytes]=0;
fwrite(my_word, my_word_length_in_bytes+1, 1, my_file);
word
実際にファイルに書き込む前に最後に「\ 0」文字を連結するか(最善の解決策)、0x00バイト(「\ 0」のASCIIコード)で2番目のfwriteを実行できます。
`fputc('\0', my_file);` will do it for you
古いトリックは、空のヌル終了文字列を使用することです
fwrite("", 1, 1, my_file);