C++ Jokes!
Catfish2 (666)
Nov 15, 2012 at 2:59pm UTC
std::string printThis("Hello, Cruel\0World!" );
It's only too bad that neither does std::string 's constructor. ;)
L B (3327)
Nov 15, 2012 at 3:07pm UTC
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 Nov 15, 2012 at 3:09pm UTC
Catfish2 (666)
Nov 15, 2012 at 4:01pm UTC
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)
Nov 15, 2012 at 4:50pm UTC
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 Nov 15, 2012 at 4:52pm UTC
legitiment1337 (64)
Nov 21, 2012 at 12:31am UTC
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)
Nov 21, 2012 at 4:56am UTC
Correction: he puts a log on the fire to log on and takes a log off the fire to log off.
Filiprei (132)
Nov 21, 2012 at 5:10am UTC
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)
Nov 21, 2012 at 5:24pm UTC
1 2 3 4 5 6
int main()
{
int C;
C = 0;
C++; // increased C, return old value.
}
L B (3327)
Nov 22, 2012 at 12:27am UTC
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... :(