Re: another fwrite() problem
- From: "tmp123" <tmp123@xxxxxxxxx>
- Date: 6 Jan 2006 07:34:16 -0800
ibrahimover@xxxxxxxxx wrote:
> 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[i] to File*/
> for(i=0;i<2;i++){
>
> fwrite(d[i],sizeof(DENEME),1,f1); //if i try like this there is an
> error'cannot convert '
>
> fwrite(&d[i],sizeof(DENEME),1,f1) // if i try like this this time it
> writes the value of pointers
>
>
>
>
> fwrite(d[i],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[i] so that
> with one read i can have d[i].i[j].name
fwrite( &d[i].i[j].name,... ) ??
.
- Follow-Ups:
- Re: another fwrite() problem
- From: tmp123
- Re: another fwrite() problem
- References:
- another fwrite() problem
- From: ibrahimover
- another fwrite() problem
- Prev by Date: Re: strcpy() - dangerous? [Was Re: gets() - dangerous?]
- Next by Date: Re: SQLServer360.com
- Previous by thread: Re: another fwrite() problem
- Next by thread: Re: another fwrite() problem
- Index(es):
Relevant Pages
|
|