Code:
#include <stdio.h>
const int MAXSIZE = 20;
int main() {
// Declaring variables
int month, day, year;
double temp;
char filename[MAXSIZE];
// File pointer
FILE* ifp;
// Ask user for month and day of wedding
printf("What is the month and day of your wedding?\n");
scanf("%d%d", &month, &day);
// Ask user for filename and opens the file
printf("What file stores your city's temperature data?\n");
scanf("%s", filename);
ifp = fopen(filename, "r");
while (1) {
// Get this day's readings
fscanf(ifp, "%d%d%d%lf", &month, &day, &year, &temp);
if (month == -1)
break;
}
printf("%d", &month);
fclose(ifp);
return 0;
}
When I run this it does not print out anything. Why is that? What I am trying to do is make sure the compiler is really reading in the values from a text file so the printf statement will not be part of my actually program just making sure I am doing things right. However, nothing is printed onto the screen when i run the program. So help me out with this one please. I really appreciate it!