Hi, was just wondering what does c_str() really do..I use it a lot when I am forced to pass pointers to a string in allegro...but no idea what it does.
does that mean it copies the string from the string object, adds the terminating null character in a separate memory address?Generates a null-terminated sequence of characters (c-string) with the same content as the string object and returns it as a pointer to an array of characters.
A terminating null character is automatically appended.
When using the printf(..) it appears they have different addresses..so in that case wouldn't it better to use the char* from the very beginning?
Also one thing I noticed is when I did this
The first printf would print the addresses..the second wouldn't..if i used %s on both to see the content it, crashes...i don't know why it should..printf() is still part of C++..?Code:printf("%p %p", d, s) ; printf("%p %p", s, d) ;