in reply to Re: Read structure in Perl
in thread Read structure in Perl
#include <stdio.h> #include <string.h> #include <malloc.h> #define DSZ 108 struct stud { char name[100]; int roll_no; }; struct student { struct stud s; int grade; }value; int main() { FILE *fps; struct student *buffer=(struct student*)malloc(sizeof(struct s +tudent)); int n,j; fps=fopen("Myfile","wb+"); value.s.roll_no=149; value.grade=1; strcpy(value.s.name,"myname"); n=fwrite(&value,DSZ,1,fps); rewind(fps); n=fread(buffer,DSZ,1,fps); printf("Name:%s Grade:%d NO:%d\n",buffer->s.name,buffer->grade +,buffer->s.roll_no); fclose(fps); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Read structure in Perl
by BrowserUk (Patriarch) on Mar 22, 2010 at 12:17 UTC | |
by Anonymous Monk on Mar 22, 2010 at 12:42 UTC | |
|
Re^3: Read structure in Perl
by syphilis (Archbishop) on Mar 22, 2010 at 13:35 UTC |