您的位置:首页 > 其它

如何把数据保存成16进制写入文件

2014-10-10 14:57 323 查看
#include <stdio.h>
#include <string.h>

int main(int argc,char *argv[])
{
char *strTest = "hello world";
int strLen=strlen(strTest);
int i=0;
FILE *fp;
if((fp=fopen("text.txt", "wb")) == NULL)
{
printf("file open failed!");
return 0;
}
printf("%d\n",strLen);
while(i<strLen)
{
fprintf(fp,"%02x",strTest[i++]);
}
return 1;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: