Page 2 of 2

Re: leave C++ strings. get on the char* boat.

Posted: Sun Dec 14, 2008 11:37 pm
by Arce
Just host via FileZilla? ;P

I do that sometimes when i need to access home shit from different location. Compliments, marauder. ;P

Re: leave C++ strings. get on the char* boat.

Posted: Sun Feb 01, 2009 7:45 am
by BOMBERMAN
Thanks avansc. Really useful topic :)

Re: leave C++ strings. get on the char* boat.

Posted: Sun Feb 01, 2009 10:22 am
by Ginto8
I see what you're saying avansc, but there's really not too much difference between char*'s and strings. And strings are almost MORE flexible.

1) both of them are arrays:

Code: Select all

char *c_string = "Hi\n"
string cplusplus_string = "Hi\n"

cout << c_string << cplusplus_string;
cout << c_string[0] << cplusplus_string[0]
I may be wrong, but this should output:
Hi
Hi
HH
2) strings let you decide whether you want to pass a char* or a string to a function, if you're passing it to a function. It can also "become" a const char* for things like opening files by using c_str(), but with char*'s I guess you could const_cast it?

3) strings have quite a few functions to make it easier to do certain things with a string (see here.

If I'm incorrect at any point, please correct me; I can't say that I'm an expert with either strings or char*'s, I was just putting in my two cents.