Hey, I know there's a very simple explanation and a very simple answer to my question, I just don't know what it is as I am very new to C++
I am trying get my program to recognise an input of either N, S, E and W so that I can use if statements based on these values. This is for a bigger project concerning the aspect of a slope, and thus various other calculations depend on the slope, thus I need my program to be able to recognise the difference between an input of N, S, E or W.
At the moment I have this
but this always gives me an output of "east" no matter what input I give it!Code:#include <iostream> using namespace std; int main () { char aspect; char N; char S; char E; char W; cin>>aspect; cin.ignore(); if(aspect = N){ cout<<"\n\n north"; } if(aspect = S){ cout<<"\n\n south"; } if(aspect = E){ cout<<"\n\n east"; } if(aspect = W){ cout<<"\n\n west"; } else cout<<"invalid input. quitting."; cin.get(); }
Any ideas why this is the case? Am I missing something obvious??
Thanks a lot
Jake