Hi,
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];
for(x=0;x<MAX;x++)
{
text[x]=(char *)calloc(MAX,sizeof(char));
}
ifp=fopen("in.txt","r");
fread(text[0],sizeof(char*),1,ifp);
printf("first word is %s\n",text[0]);
fclose(ifp);
return 0;
}