J
Jim Langston
I'm using a function like this:
char TextBuffer[261];
jGet_DropDown_Selected_Text( cc.ddSex, TextBuffer);
Where the function is filling in the text buffer. I don't have access to
the actual function to change it to a std::string (it's a library function)
so I was thinking, well, I could use a std::vector<char> instead of a char
array, but would that actually gain me anything at all? I mean, what's the
difference between calling it like the previous, and calling it like this:
std::vector<char> TextBuffer;
TextBuffer.resize(261);
jGet_DropDown_Selected_Text( cc.ddSex, &TextBuffer[0]);
with any needed casting I may need.
Now, if std::string could be called this way it would be wonderful! I would
just live to do:
std::string TextBuffer;
TextBuffer.resize(261); // or similar
jGet_DropDown_Selected_Text( cc.ddSex, TextBuffer.c_str());
But as I'm sure most of us are aware, c_str() returns a const char * and
can't be used this way (the main reason std::string isn't used instead of
char arrays IMO).
So, should I just stay with the char array?
char TextBuffer[261];
jGet_DropDown_Selected_Text( cc.ddSex, TextBuffer);
Where the function is filling in the text buffer. I don't have access to
the actual function to change it to a std::string (it's a library function)
so I was thinking, well, I could use a std::vector<char> instead of a char
array, but would that actually gain me anything at all? I mean, what's the
difference between calling it like the previous, and calling it like this:
std::vector<char> TextBuffer;
TextBuffer.resize(261);
jGet_DropDown_Selected_Text( cc.ddSex, &TextBuffer[0]);
with any needed casting I may need.
Now, if std::string could be called this way it would be wonderful! I would
just live to do:
std::string TextBuffer;
TextBuffer.resize(261); // or similar
jGet_DropDown_Selected_Text( cc.ddSex, TextBuffer.c_str());
But as I'm sure most of us are aware, c_str() returns a const char * and
can't be used this way (the main reason std::string isn't used instead of
char arrays IMO).
So, should I just stay with the char array?