Help comparing a string with 0

Is this correct:

1
2
3
4
5
6
7
8
9
	cout<<"Type the offers till you type '0' for end"<<endl;
	do
	{
		cout<<"Type the name of the buyer:"<<endl;
		cin>>av;
		cout<<"Type the price"<<endl;
		cin>>ce;
	}
	while(av[0]!='0');


What I want to do here is, read offers, till the users types '0' (zero) for END.
I try typing 0, but it doesn't stop :/
What is av?
Last edited on
it's a char av[50];
Sorry I forgot to state that.
It seems that the code has to work correctly exiting the loop then 0 will be entered.
simply add a if statement to check for '0' input before asking for other input
1
2
3
4
5
6
7
8
9
10
11
12
cout << "Type the offers till you type '0' for end" << endl;
do
{
   cout << "Type the name of the buyer:" << endl;
   cin >> av;
   if (av[0] != '0')
   {
      cout << "Type the price" << endl;
      cin >> ce;
   }
}
while(av[0] != '0');

I just replaced it with an infinite 'for' cyclus.
thank you
Topic archived. No new replies allowed.