While Loop not workig?!?!

Hi I have the following loop:
1
2
3
4
5
6
7
while(s!=-1){

	cin>>s>>p>>m;
	
      a[s-1][p-1]=m;

	}


and when I input -1 for "s", the program wont exit the loop right away, it continues with asking the user for variable "p" and "m"!! How do I fix that!

Thank you for your time!
1
2
3
4
while( (cin>>s) && (s!=-1) && (cin>>p>>m) )
{
    a[s-1][p-1] = m;
}
are you asking the user for 's' outside of the loop, because it looks like you are having the user input the value for 's' inside the loop.
Topic archived. No new replies allowed.