LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   c++ multi-character constant error? (https://www.linuxquestions.org/questions/programming-9/c-multi-character-constant-error-262910/)

azucarmom 12-05-2004 02:07 PM

c++ multi-character constant error?
 
Hi! I'm new to the board and am nearing the end of my first c++ class. I have the following code:


void GetQuantity(string descr, int& qty)
{
int amount;
cout << "How many " << descr << " would you like to purchase?" << endl;
cin >> amount;

while ((qty+amount < 0)||(!cin))
{
cin.clear();
cin.ignore(256, '/n');
cout << "************************************************" << endl;
cout << "I'm sorry, the quantity you entered is not valid" << endl;
cout << "************************************************" << endl << end
cout << "You have chosen " << qty << " " << descr << "so far," << end
cout << "How many more would you like to purchase?" << endl;
cin >> amount;
}

qty = qty + amount;
}

I get the following error when I compile:
p7.cpp:373:23: warning: multi-character character constant

Line 373 is the

cin.ignore(256, '/n');

What am I doing wrong there?

Thanks to anyone who can help....

azucarmom

Tinkster 12-05-2004 02:12 PM

Try '\n' instead of '/n' ...


Cheers,
Tink

Mara 12-05-2004 02:16 PM

Use '\n' instead of '/n'. '/n' is interpreted as two characters, '/' and 'n'.

Mara 12-05-2004 02:17 PM

I was slower... :)

azucarmom 12-05-2004 07:13 PM

Thanks everyone!! That was exactly the problem. <sigh> For some reason I thought I had already done that and it hadn't worked. Brain freeze...


All times are GMT -5. The time now is 01:46 AM.