hi i have a 3 part question. can any one explain how can i read from a file and store it in array.(have to use fread).
the way i was thinking of doing this was.

int ar[50]; 
int ar2[50];
//read 20 charater at a time
while(fread(ar, 1, 20, file) != NULL)
{
        ar2[i] = ar;
}

partb:
how read one word at a time, by using fread.

while(fread(ar, SIZE, file) != 0) 
     {
     }

part3:
how read one line at a time, by using fread. i think its

while(fread(ar, SIZE, file) != 0) 
     {
     }

while(fread(ar, 1, 20, file) != NULL)
That only reads 20 bytes of data instead of 20 * sizeof(int) number of bytes. You need this?

while(fread(ar, 20, sizeof(int), file) != NULL)

how read one line at a time,
You mean how to read one integer at a time?

int i = 0;
while( fread( &ar[i], 1, sizeof(int), file) != NULL)
   ++i;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.