linux C write 1 bytes data to file

#include <string.h>
#include <stdio.h>

int main(int argc,char *argv[])

{
FILE *fp;
if((fp=fopen("./1_byte.txt","wb")) == NULL)
{
printf("file open failed!");
return -1;
}
unsigned char tmp[1] = {0x10};
fwrite(tmp, 1, 1, fp);
printf("write down.\n");
return 0;
}

This test can used for padding data. For example: 32bytes align.

posted @ 2016-06-04 10:08  JustRelax  阅读(178)  评论(0编辑  收藏  举报