+ 1
How do i store the length of a string in a variable?
In cpp
3 Respostas
+ 5
Blazinghelmet
int len = str.length()
+ 1
Choose either one, a little note, all three are unsigned integer types. Where `auto` means compiler deduce the type of <len>.
std::string::size_type len {your_string.size()};
Or
std::size_t len {your_string.size()};
Or
auto len {your_string.size()};
+ 1
#include<string.h>
...
int i = strlen(your string);