c-str Questions
7
Solved
I understand c_str converts a string, that may or may not be null-terminated, to a null-terminated string.
Is this true? Can you give some examples?
6
I have read several places that the difference between c_str() and data() (in STL and other implementations) is that c_str() is always null terminated while data() is not.
As far as I have seen in ...
4
Solved
After C++11, I thought of c_str() and data() equivalently.
C++17 introduces an overload for the latter, that returns a non-constant pointer (reference, which I am not sure if it's updated complete...
7
Solved
In one of my programs, I have to interface with some legacy code that works with const char*.
Lets say I have a structure which looks like:
struct Foo
{
const char* server;
const char* name;
};
...
3
Solved
In the C++ reference of c_str() in std::string the following appears:
Return value
Pointer to the underlying character storage.
data()[i] == operator[](i) for every i in [0, size()) (until C++...
3
Solved
I've read various descriptions of std::string::c_str including questions raised on SO over the years/decades,
I like this description for its clarity:
Returns a pointer to an array that contai...
1
I'm playing around with a new init system with #![no_std] and extern crate rlibc and making syscalls with asm, and currently trying to not allocate memory either. So the scope of possible tools I h...
3
Solved
Why would I ever want to call std::string::data() over std::string::c_str()? Surely there is some method to the standard's madness here...
4
Solved
This is from a small library that I found online:
const char* GetHandStateBrief(const PostFlopState* state)
{
static std::ostringstream out;
// ... rest of the function ...
return out.str().c...
Hydroxy asked 17/4, 2010 at 4:3
1
© 2022 - 2024 — McMap. All rights reserved.