Linked Questions

41 votes
7 answers
37k views

I have seen code around with these two styles , I am not not sure if one is better than another (is it just a matter of style)? Do you have any recommendations of why you would choose one over ...
kal's user avatar
  • 29.6k
18 votes
5 answers
50k views

Possible Duplicate: C++ char* vs std::string I'm new to C++ coming from C# but I really do like C++ much better. I have an abstract class that defines two constant strings (not static). And I ...
Noah Roth's user avatar
  • 9,280
2 votes
2 answers
922 views

Possible Duplicate: C++ char* vs std::string Is there any advantage to using char*'s instead of std::string? I know char*'s are usually defined on the stack, so we know exactly how much memory we'...
Lockyer's user avatar
  • 1,431
258 votes
22 answers
252k views

In our C++ course they suggest not to use C++ arrays on new projects anymore. As far as I know Stroustrup himself suggests not to use arrays. But are there significant performance differences?
tunnuz's user avatar
  • 24.2k
156 votes
7 answers
312k views

For C, we use char[] to represent strings. For C++, I see examples using both std::string and char arrays. #include <iostream> #include <string> using namespace std; int main () { ...
ramosg's user avatar
  • 2,096
23 votes
7 answers
77k views

If I have a pointer that points to a string variable array of chars, is there a difference between typing: char *name = "name"; And, string name = "name";
Simplicity's user avatar
  • 49.4k
9 votes
1 answer
9k views

I need a deep technical explanation of what I'm about to ask, not a solution. Ive been learning pointers for a week now, I understand it pretty well. But while writing a program, I stumbled upon this ...
userX's user avatar
  • 390
3 votes
3 answers
4k views

I am developing an application of which the core code base would be cross-platform for Windows, iOS and Android. My question is: how should I internally represent strings used by this app to be able ...
Mark Vincze's user avatar
  • 8,115
4 votes
3 answers
3k views

I want to use a string constant in multiple places in my cpp file. Should I use std::string or char[]? static const std::string kConstantString = "ConstantStringValue"; static const char ...
theraju's user avatar
  • 471
1 vote
4 answers
272 views

Let say I am designing an interface, to return the name of the child class. Note that, for different instance of a child class, their name shall remain the same. For speed and memory efficient, I ...
Cheok Yan Cheng's user avatar
1 vote
5 answers
3k views

class Student { public: string name; }; vs class Student { public: char* name; }; Please correct me if I'm wrong. If we were to use char* instead of string, we will have to ...
abcde's user avatar
  • 545
2 votes
2 answers
592 views

I have seen char* vs std::string in c++, but am still wondering if accessing the elements of a char* is faster than std::string. If you need to know, the char*/std::string will contain less than 80 ...
Flare Cat's user avatar
  • 621
-3 votes
2 answers
3k views

What's the difference between std::string and const char*? consider following example #include <iostream> #include <string> int main() { const char* myName1{ "Alex" }; ...
Amirhossein Nikravan's user avatar
0 votes
2 answers
2k views

I am using MSVC++ 2010 Express, and I would love to know how to convert BYTE Key[] = {0x50,0x61,0x73,0x73,0x77,0x6F,0x72,0x64}; to "Password" I am having a lot of trouble doing this. :( I will use ...
user954753's user avatar
1 vote
3 answers
1k views

I have the trans function which uses a single parameter, has to be void, and returns through c the opposite case of a letter from a word input in main. Example: input: dOgdoG output: DoGDOg The ...
MickeyMoise's user avatar

15 30 50 per page