>>scanf ( "%s", &rainfall );
%s wants a character array of at least 2 bytes. rainfall is not a character array, so the above will always fail to work correctly.
char rainfall[2]; // 1 byte for either Y or N and secnd byte for null terminator
scanf ( "%s", &rainfall );
There are probably other problems, but I stopped reading after that line.
[edit]barometer has the same problem. Where do you declare variables storm etc ? Post them too.[/edit]
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
Also, you probably want to compare barometer to a range, rather than a specific value. Perhaps something like:
// assuming storm is low, and better weather is higher
if(barometer <= storm)
// ...
else if(barometer <= rain)
// ...
else if(barometer <= fair)
/* etc... */
The ranges will be determined as the lowest category the barometer value fits into, and by using else if you won't have conflicts.
Infarction
Posting Virtuoso
1,580 posts since May 2006
Reputation Points: 683
Solved Threads: 53