By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,972 Members | 1,115 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,972 IT Pros & Developers. It's quick & easy.

char*

P: 1
when can use e char* and whats e advantage of it?
Jun 19 '07 #1
Share this Question
Share on Google+
4 Replies


Meetee
Expert Mod 100+
P: 931
Hi,

char * is a pointer to a character. One advantage that using a string has over your char * code is that the string version doesn't leak memory. When you use char *, you have the pitfall of memory leak. You always need to delete the pointer at the end while using char *.

string is safer. If it is implemented properly, it can prevent buffer
overflows that commonly take place when you don't take care of your char
array properly.

Regards.
Jun 19 '07 #2

P: 6
NOT SEEN THIS TYPE OF CODE

i think you will be having some typedef definition before that code line
Jun 19 '07 #3

Expert 10K+
P: 11,448
NOT SEEN THIS TYPE OF CODE

i think you will be having some typedef definition before that code line
The previous poster was talking about C++ where the string type is implemented
and indeed gives you quite some functionality and safety on top of just raw char
pointers (which are common in C).

kind regards,

Jos

ps. There's no need to shout.
Jun 19 '07 #4

P: 6
.................................................. .................................................. .................................................. ..............
Jun 20 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.