Sportica   Sportica

C以二进制读、写、文本

#define  OSD_FILEF "/home/OsdSave.txt"
typedef struct textOSD_s
{
int font_size;
int outline;
int bold;
int italic;
int color;
}textOSD_t;

void saveRead()
{
memset(&osd_t,0,sizeof(textOSD_t));
if((osdfp=fopen(OSD_FILE,"wb"))==NULL) //打开一个文件,以二进制向文本中写入
{
printf("can not open file \n");
return;
}
else
{
fwrite(&osd_t,sizeof(textOSD_t),1,osdfp); //
}
fclose(osdfp); //关闭


if((osdfp=fopen(OSD_FILE,"rb"))==NULL) //打开一个文件。以二进制的方式来读
{
printf("can not open file \n");
return;
}
else
{
fread(&osd_t,sizeof(textOSD_t),1,osdfp); //
}
fclose(osdfp); //关闭
}
posted @ 2011-12-02 16:13  qingjoin  阅读(331)  评论(0编辑  收藏  举报
  Sportica