C++ Jokes!

Pages: 1234
Catfish2 (666)
std::string printThis("Hello, Cruel\0World!");
It's only too bad that neither does std::string's constructor. ;)
L B (3327)
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
Catfish2 (666)
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. ;)
L B (3327)
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
legitiment1337 (64)
This is only for jokes, no corrections. :)

How do you know if a redneck uses a computer?

He calls the mouse a "critter".
L B (3327)
Correction: he puts a log on the fire to log on and takes a log off the fire to log off.
Filiprei (132)
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!!
legitiment1337 (64)
1
2
3
4
5
6
int main()
{
     int C;
     C = 0;
     C++; // increased C, return old value.
}
L B (3327)
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... :(
Registered users can post here. Sign in or register to post.
Pages: 1234