I\'m trying to use fscanf to read and print every character on the screen, but I\'m getting a segmentation fault (core dumped) when I run the program. Here\'s my code:
When you write:
int *a;
then a is a pointer, but currently it does not point anywhere.
You have to make it point to valid storage for an int, before you supply it to fscanf.
For example, inside main():
int b;
a = &b;
fscanf(input,"%d\n",a);
Also, your loop is wrong. It is almost always an error to use feof (let alone, as a loop condition). Instead, you should test the actual read operation. In your case:
while ( 1 == fscanf(input,"%d\n",a) )
{
printf("%d\n", a);
}