#include <stdio.h>
#include <string.h>
int main( void )
{
 FILE *stream;
 typedef struct _tt{
  int a;
  int b;
  char buf[20];
 }tt;
 tt temp;
 temp.a=10;
 temp.b=20;
 strcpy(temp.buf,"hello");
 
 int c=sizeof(temp);
 stream= fopen("at.dat","w+");
 fwrite(&temp,sizeof(temp),1,stream);
 
 char *pbuf=new char[sizeof(temp)];
 
 fseek(stream,0,SEEK_SET);
 fread(pbuf,sizeof(temp),1,stream);
    fclose(stream);
    tt *p=(tt*)pbuf;
 printf("%d %d %s",p->a,p->b,p->buf);
}

相关文章:

  • 2021-05-30
  • 2021-05-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-24
  • 2021-11-13
  • 2021-08-24
  • 2022-12-23
  • 2021-11-30
  • 2021-05-18
相关资源
相似解决方案