How to display data from a file?
Hey guys, today I'm trying to display data from a text file named ace_data.txt. Here's a preview of the first three lines i want to display:
2001 106 15
2002 65 12
2003 175 16
So basically, here is what my code looks like...
Code:
#define FILENAME "ace_data.txt"
int main (void)
{
FILE *inp,
*outp;
inp = fopen("FILENAME", "r");
outp = fopen("ace_data.out", "w");
if (inp == NULL )
printf("Error opening file. Ending program...\n");
else{
fscanf(inp, "%d %d %d \n") }
}
...and nothing is displayed when i run the program. I feel like I made some mistake with the fopen() and fscanf() functions but I'm not so sure how to correct them. Thanks in advance!