简体   繁体   中英

C++ fwrite() in hex

Writing code with Winsock.
I currently have this:

fwrite(buff, 1, len, stdout);

How to do it like:

for ( int i = 0; i < len; i++ ) {
printf( "%02x ", unsigned char (buff[i]) );
}
printf( "\n" );

Or should I just remove the fwrite and use the print instead?
I wanted to write it to stdout, cuz I have my option to either write to stdout of write to file.

fprintf (参见文档 )就像printf但是对于任意文件:

fprintf(stdout, "%02x ", unsigned char (buff[i]));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM