D
D
Daniil Demidko2015-12-12 09:01:24
C++ / C#
Daniil Demidko, 2015-12-12 09:01:24

Does the size() method of the std::string class return the entire length of the string?

For example:

std::string line="abc";
int size=line.size(); // size == 3
// 'a' - 1 'b' - 2 'c' - 3

But what about the terminating null character in a string?
Does it not count?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Armenian Radio, 2015-12-12
@Daniro_San

std::string does not use the null character to store the terminator.
This, in particular, means that arbitrary data, including zeros, can be placed in std::string.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question