Hello,
I am a new user to Daniweb. My regards to all.
Well my C skills have taken a lot of rust and I am stuck at a small issue.
I want to read a data file containing some information. Now I want to read 2 integers from this file, add them and store them in a character array. I need this array for other filename.
For a start, I am trying to read only the first integer, stored at position 10 on the first line. But I am getting segmentation fault when I execute. Can some one point out whats wrong ?
Here is the code:
#include<stdio.h>
#include<stdlib.h>
main()
{
FILE *fp;
int buffer;
char c;
fp = fopen("mfdn.dat", "rb+" );
fseek(fp,10,SEEK_SET);
fread(buffer, sizeof(buffer), 1, fp);
printf("buffer is : %c\n", buffer );
fclose(fp);
}
I get this error:
filename.c: In function `main':
filename.c:13: warning: passing arg 1 of `fread' makes pointer from integer without a cast
Segmentation fault
Please advise me on this.
Cheers