i am learning C++ from a good time now.. but I am still very confused sometimes in the use of array(char) and string.. can anyone please tell me that what exactly all differences between string and char array ? what can i do with array which i can't do with string and vice-versa ? searched google alot but on each place something confusing is written. thanks in advance to you.
nitin1
15
Master Poster
Recommended Answers
Jump to PostA char array is just that. Some char objects all next to each other in memory, typically with a zero value on the end. It is up to you to allocate it, keep track of how big it is, make sure you don't write or read off the end of …
Jump to PostGive this link a try to see what a string can do.
The string object even gives you a function enabling you to pretend it is just an array of char, in case you're stuck with a function that wants an …
Jump to Postand if it is pointer, then why do you still need to use c_str() ?
Array of charaters are considered (in C++) to be C style strings, where they would be just a sequence of characters in the memory.
string
on the other hand, is a C++ class that …
All 11 Replies
Moschops
683
Practically a Master Poster
Featured Poster
nitin1
15
Master Poster
Moschops
683
Practically a Master Poster
Featured Poster
nitin1
15
Master Poster
NathanOliver
429
Veteran Poster
Featured Poster
nitin1
commented:
nice!!
+2
NathanOliver
429
Veteran Poster
Featured Poster
nitin1
15
Master Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
Moschops
683
Practically a Master Poster
Featured Poster
NathanOliver
429
Veteran Poster
Featured Poster
Lucaci Andrew
140
Za s|n
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.