you can't say values[x].city = s ... you must do something like strcpy(values[x].city, s) ... also dont put the "&s" when getting a string. just put "s"
while (fscanf(inp,"%s %d",s, &n) != EOF)
{
strcpy(values[x].city, s);
values[x].temp = n;
x++;
}
the reason is that "s" and "values[x].city" are actually pointers to a character array, and you can't simply make an assignment to copy the array.
jephthah
Posting Maven
2,587 posts since Feb 2008
Reputation Points: 2,143
Solved Threads: 179
Nice. Try it with the city Des Moines or Los Angeles and let us know how it works.
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
following his posted .TXT file example, i can see that Des_Moines and Los_Angeles will work just fine.
:P
jephthah
Posting Maven
2,587 posts since Feb 2008
Reputation Points: 2,143
Solved Threads: 179
That'll teach me to look first...
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944