error multicharacter constant

i am getting an error of multicharacter constant for the line SENTINEL='-1' .i am not able to understand why.can anyone please help me out of this.iam tryig to run this program in codeblocks.

#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
int main()

{
const string SENTINEL;
SENTINEL='-1';
string name;
int noofvolunteers,noofboxsold,totalnofboxsold;
double costofbox;
cout<<fixed<<showpoint<<setprecision(2);
cout<<"Enter the name of the volunteers and the no of boxes sold by them ending with -1"<<endl;
totalnofboxsold=0;
noofvolunteers=0;
cin>>name;
while(name!=SENTINEL)
{
cin>>noofboxsold;
totalnofboxsold=totalnofboxsold+noofboxsold;
noofvolunteers++;
cin>>name;

}
cout<<endl;
cout<<"The total no of box sold:"<<totalnofboxsold<<endl;
cout<<"Enter the cost of the box:"<<endl;
cin>>costofbox;
cout<<endl;
cout<<"The total money made by selling the cookies"<<totalnofboxsold*costofbox<<endl;
if(noofvolunteers!=0)
{
cout<<"The average no of boxes sold by each volunteers is: "<<totalnofboxsold/noofvolunteers<<endl;
}
else
{
cout<<"No input"<<endl;
}
return 0;
}
Use single quotes ' only for a char, and double quotes " for a string.

Also, you shouldn't declare a string as const on one line ... and change its value on the next!

It seems unusual to use a numerical quantity as a sentinel when the usual input here is a string.

When you have fixed your compile errors you may want to tidy up the output statements (it will become clear where you need to add a space). noofvolunteers will also be out by 1.


Please put code tags around your code sample.
Last edited on
Topic archived. No new replies allowed.