0

How we use sizeof in string?

8th Nov 2019, 2:42 PM
ashutosh apurva
ashutosh apurva - avatar
3 odpowiedzi
+ 2
C++ : Using sizeof with a string results in the size of whole string. Example:- char str[10]="Sololearn"; cout<<sizeof(str); Output will be 10 (one character occupies 1 byte, so a 10 character string will be of 10 bytes) 🤟
8th Nov 2019, 2:49 PM
Harshit Sharma
Harshit Sharma - avatar
0
👍👍👍
8th Nov 2019, 2:52 PM
ashutosh apurva
ashutosh apurva - avatar
0
int sizeOfStr = sizeof(str) / sizeof(char);
8th Nov 2019, 3:27 PM
o.gak
o.gak - avatar