I
ibrahimover
typedef struct{
char name[10];
int no;
}TAM;
typedef struct{
char name[10];
char ch;
}HARF;
typedef struct{
TAM *i;
CHAR *c;
}DENEME;
main(){
FILE *f1;
DENEME *d;
d=(DENEME *) malloc(sizeof(DENEME)*2);
int i;
d[0].i=(TAM *) malloc(sizeof(TAM)*2);
d[0].c=(HARF *) malloc(sizeof(HARF)*2);
d[1].i=(TAM *) malloc(sizeof(TAM)*2);
d[1].c=(HARF *) malloc(sizeof(HARF)*2);
/* Every think ok for now i can get info from user like
(d[0].i[0].name,d[0].i[0].no) */
f1=fopen("c:\\deneme.txt","w+b");
/* i just wnt to write d to File*/
for(i=0;i<2;i++){
fwrite(d,sizeof(DENEME),1,f1); //if i try like this there is an
error'cannot convert '
fwrite(&d,sizeof(DENEME),1,f1) // if i try like this this time it
writes the value of pointers
fwrite(d,sizeof(TAM)*2+sizeof(HARF)*2,1,f1)// finally i try this but
it gives error agin
}
}
im able to write like this
fwrite((d+0)->i,sizeof(TAM),2,f1);
fwrite((d+0)->c,sizeof(HARF),2,f1);
but i doesnot help for my algorithms cause i want to read d so that
with one read i can have d.i[j].name
hope im could explain my problem clearly..
sorry for my english
char name[10];
int no;
}TAM;
typedef struct{
char name[10];
char ch;
}HARF;
typedef struct{
TAM *i;
CHAR *c;
}DENEME;
main(){
FILE *f1;
DENEME *d;
d=(DENEME *) malloc(sizeof(DENEME)*2);
int i;
d[0].i=(TAM *) malloc(sizeof(TAM)*2);
d[0].c=(HARF *) malloc(sizeof(HARF)*2);
d[1].i=(TAM *) malloc(sizeof(TAM)*2);
d[1].c=(HARF *) malloc(sizeof(HARF)*2);
/* Every think ok for now i can get info from user like
(d[0].i[0].name,d[0].i[0].no) */
f1=fopen("c:\\deneme.txt","w+b");
/* i just wnt to write d to File*/
for(i=0;i<2;i++){
fwrite(d,sizeof(DENEME),1,f1); //if i try like this there is an
error'cannot convert '
fwrite(&d,sizeof(DENEME),1,f1) // if i try like this this time it
writes the value of pointers
fwrite(d,sizeof(TAM)*2+sizeof(HARF)*2,1,f1)// finally i try this but
it gives error agin
}
}
im able to write like this
fwrite((d+0)->i,sizeof(TAM),2,f1);
fwrite((d+0)->c,sizeof(HARF),2,f1);
but i doesnot help for my algorithms cause i want to read d so that
with one read i can have d.i[j].name
hope im could explain my problem clearly..
sorry for my english