Languages

C++ - get number of bytes allocated by std::string in memory

8 points
Asked by:
sienko
743

Is it posible to check how many bytes uses std::string object in c++?

1 answer
1 points
Answered by:
Root-ssh
178180

Yes, it is.

Use size_t capacity() function.

Check this code:

Output:

 

0 commentsAdd comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join