-
- Để tính độ dài của một chuỗi, ta sử dụng hàm length()
- Ví dụ:
#include <iostream> using namespace std; int main () { string txt = "ABCD"; cout << "Do dai cua chuoi txt là: " << txt.length(); return 0; }
– Kết quả:
– Ngoài ra, các bạn cũng có thể sử dụng hàm size() để lấy độ dài của chuỗi.
Ví dụ:
#include <iostream> using namespace std; int main () { string txt = "ABCD"; cout << "Do dai cua chuoi txt là: " << txt.size(); return 0; }
– Kết quả tương tự hàm length()
I have read a feww excelent stuff here. Definitely value
bookmarking for revisiting. I wonder how much effort you put to make
any such fantastic informative website.
Here is my site; Youtube