Hi guys,
Ultra nooby question here. Just doing an assignment, and I've got my array setup working and printing out as it should, but I'm using scanf to take input.. and the input file we're given starts with string column headers (which we don't need to store).
scanf goes EOF when it reads these characters first, and hence I'll just get a bunch of garbage when it prints with whatever's in memory. What should I be using to take the number inputs to integers, while ignoring the text at the top? I can't for the life of me remember how this is done. This is what I have storing the input:
Code:
for (i=0; i < ROWS; i=i+1) {
scanf("%d", &month[i]);
scanf("%d", &year[i]);
scanf("%d", &postcode[i]);
scanf("%d", &bedrooms[i]);
scanf("%d", &price[i]);
}
And this is the input file:
Code:
Month Year Postcode Bedrooms Price
12 2008 2033 3 783000
7 2009 2034 4 777000
12 2008 2034 4 821000
3 2008 2034 3 781500
2 2009 2034 4 847000
11 2008 2032 3 729000
7 2008 2034 4 768500
12 2009 2034 4 868000
4 2009 2033 5 746000
2 2008 2034 2 831500
I hope my question makes sense!