I have a problem with fread,i wrote that program
and in the input file only "Hello Word".
the out put of the program only prints "Hell"
and when I increase the elements in fread to 2 it
outputs "Hello Wo".
so for each element in fread it reads 4
characters (note i am using sizeof(Char*)
Please help..Thanks in advance.
Here is my code:

int main(void)
int x;
FILE *ifp;
char *text[MAX];
	text[x]=(char *)calloc(MAX,sizeof(char));
printf("first word is %s\n",text[0]);
return 0;

That is opening the file in text mode while fread() expects binary mode. Suggest you replace fread() with fgets() if you want to keep text mode.


sizeof(char*) is always the sjze of a pointer, which on MS-Windows and *nix 32-bit compilers is 4. And that's why fread() is only reading 4 characters.

thanks for your reply..
it helped alot..
how can i get what inside the file to a single destination?
as fgets works line by line..
thanks in advance.