Re: complex variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"fread and fwrite return the  number of items
successfully read "
well i am reading 32 complex neumbers...sorry i dont
understand why it whould be 16 and not 32?

ankit
 --- Patrick Percot <ppercot@xxxxxxx> wrote: 
> On Mon, 6 Sep 2004 13:22:15 +0100 (BST), Ankit Jain
> <ankitjain1580@xxxxxxxxx> wrote
> 
> >       1 #include<stdlib.h>
> >       2 #include<complex.h>
> >       3 #include<stdio.h>
> >       4
> >       5 int main()
> >       6 {
> >       7         FILE *fp;
> >       8         fp=fopen("test_data.dat","rb");
> >       9         int N=32,i=0;
> >      10         complex x,*in;
> >      11         in=malloc(sizeof(complex)*N);
> >      12         if (fread(in,16,32*16,fp) != 32)
> 
> The manual page says :
> 
> RETURN VALUE
>        fread and fwrite return the  number of items
> successfully read or
>        written  (i.e.,  not the  number  of 
> characters).   If an  error
>        occurs,  or the  end-of-file is  reached, the
>  return value  is a
>        short item count (or zero).
> 
> So if fread is OK, it returns 16 not 32.
> 
> >      13          printf("error in reading from
> file
> > failed\n");
> >      14         else{
> >      15         for(i=0;i<N;i++)
> >      16           printf("%lf\t",*(in+i+0));
> >      17         }
> >      18         return 0;
> >      19 }
> > 
> > it gives error
> > "error in reading the file"
> > 
> > whats wrong?
> > 
> > ankit
> > 
> >
>
________________________________________________________________________
> > Yahoo! Messenger - Communicate instantly..."Ping" 
> > your friends today! Download Messenger Now 
> > http://uk.messenger.yahoo.com/download/index.html
> > 
> 
> À+
> PP
> -- 
> Groupe Morbihannais d'Utilisateurs de Logiciels
> Libres http://www.tuxbihan.org
> GPG fingerprint = 1A4F E154 3D2C A20E E4CA  A543
> 7951 C5C2 E44A A0B5
> 
> Patrick Percot.
>  

________________________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping" 
your friends today! Download Messenger Now 
http://uk.messenger.yahoo.com/download/index.html

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux