C++: Multi-string literals are deprecated?

Started by
5 comments, last by me22 18 years, 3 months ago
I'm getting this error when I try to compile one of the example codes in my C++ book. What does it mean? I'm typing the code exactly like it is in the book. I'm using "Bloodshed Dev-C++" Also... it's trying to teach me about hex and octal values, is there any reason why I would use these instead of normal numbers?
Advertisement
sometimes the code is outdated and will be messed up. if you show us the code and the errors i may be able to help you figure it out.
// hexoct.cpp -- shows hex and octal constants
#include <iostream>
using namespace std;
int main()
{
int chest = 42; // decimal integer constant
int waist = 0x42; // hexadecimal integer constant
int inseam = 042; // octal integer constant

cout << "Monsieur cuts a striking figure!\n";
cout << "chest = " << chest << "\n";
cout << "waist = " << waist << "\n";
cout << "inseam = " << inseam << "\n";
return 0;
}

Odd thing was... I just tried to compile it on this computer, and I didn't get any errors at all...

I'm really new at this -_-
The error in question means you can't have a line break in the middle of a string, like so:
cout << "this is some
multi line string" << endl;
That you're seeing it probably means you missed a closing quotation mark somewhere.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
"deprecated" means obsolete but still supported. The compiler is letting you know that while this code will compile today it might not in the future. You can disable this sort of warning with a #pragma in most compilers.

As for the numbers, I have never in all my years programming seen an octal number anywhere other than a textbook. Hex numbers you see from time to time. The only one I've ever typed into code myself is 0xFFFFFFFF. You outta be able to read them well enough to know why someone might want 0xFFFFFFFF but apart from that, eh. The little "calc" program that comes with windows will do conversion for you, btw.

well i dont use bloodshed i use codeblocks... nicer compiler but maybe you have an outdated version
Quote:Original post by Xantan the Foul
Also... it's trying to teach me about hex and octal values, is there any reason why I would use these instead of normal numbers?

Since there are no binary literals, if you want to hardcode binary into your application, it's much easier to do so in hex, since an n-hexit hex number can be digit-by-digit expanted to a 4n-bit binary number.

0xAC is 1010 1100, for example, since 0xA is 1010(base2) and 0xB is 1100(base2)
Compare to 172, which is much harder to mentally convert to 10101100
Octal is also easy, since an octal octit expands to 3 bits: 01101100(base2) is 0254 (octal)

This topic is closed to new replies.

Advertisement