C++ Jokes!

Pages: 1234
std::string printThis("Hello, Cruel\0World!");
It's only too bad that neither does std::string's constructor. ;)
std::string MyString ("Hello, Cruel\0World!", 19);
http://ideone.com/zcq6PF
;)

Edit: You could alternatively store it in a character array (read: array, not pointer) and use some sizeof magic ;)
Last edited on
You could alternatively store it in a character array (read: array, not pointer) and use some sizeof magic ;)

... and be done with it right there. ;)
Catfish2 wrote:
... and be done with it right there. ;)
The it you refer to is this, based on what I have described:
1
2
char MyCharArray[] = "Hello, Cruel\0World!";
std::string MyString (MyCharArray, sizeof(MyCharArray)-1);
http://ideone.com/hRlIlq

So yes, you would be done with it right there, where there is immediately after the semicolon after the statement that declares and constructs MyString from MyCharArray.
Last edited on
This is only for jokes, no corrections. :)

How do you know if a redneck uses a computer?

He calls the mouse a "critter".
Correction: he puts a log on the fire to log on and takes a log off the fire to log off.
closed account (ETAkoG1T)
Razzor what book are you reading
This is a good one I just read in the book on C++ I'm reading:


I am also reading a book and it had the same joke!!
1
2
3
4
5
6
int main()
{
     int C;
     C = 0;
     C++; // increased C, return old value.
}
I hate when people use post-increment and post-decrement without using the return value properly. Sure, the compiler optimizes it, but it still drives me mental. Unfortunately it is an actual style to do it wrong like that in many coding communities...so many malformed for-loops everywhere... :(
Topic archived. No new replies allowed.
Pages: 1234