does line.length(); include end line chars?
For example
Hello World
How long would this be 11 or开发者_Python百科 12?
std::string s1 = "Hello World\n";
std::cout << s1.length() << std::endl;
This prints 12. The new line is included in the length.
yes end line character( '\n') will be counted in the length.
std::string s = "Hello World";
std::cout<< s.length()<<std::endl;
s = "Hello World\n";
std::cout<<s.length()<<std::endl;
result will be
11 12
精彩评论