C++ Dize boyutu()
Bu işlev, dizenin uzunluğunu bayt cinsinden döndürmek için kullanılır. Kapasiteye eşit olması gerekmeyen dize nesnesinin içeriğine uyan gerçek bayt sayısını tanımlar.
Sözdizimi
Olarak adlandırılan bir dize nesnesini düşünün 'str' . Bu dize nesnesinin boyutunu hesaplamak için sözdizimi şöyle olacaktır:
str.size()
Parametreler
Bu fonksiyon herhangi bir parametre içermez.
Geri dönüş değeri
Bu işlev, dize nesnesinde bulunan karakter sayısını döndürür.
örnek 1
#include using namespace std; int main() { string str ='Welcome to the javatpoint tutorial'; int size = str.size(); cout << 'length of the string is :' <<size; return 0; } < pre> <p> <strong>Output:</strong> </p> <pre> length of the string is : 34 </pre> <p>In this example, str is a string object containing value 'Welcome to the javatpoint tutorial'. We calculate the length of the string using 'size' function. </p> <br></size;> Bu örnekte str, 'javatpoint eğitimine hoş geldiniz' değerini içeren bir dize nesnesidir. 'Size' fonksiyonunu kullanarak dizenin uzunluğunu hesaplıyoruz.