Count characters | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

Count characters

i'm trying to make that the 'sizeof' function counts the size of the variable with user asigned value. The following code don't work #include<iostream> #include<string> using namespace std; int main() { int text = new int; cin >> text; cout << sizeof(text); return 0; }

8th Nov 2019, 12:22 AM
Daniel Vetter
Daniel Vetter - avatar
1 Réponse
+ 3
// Count characters #include<iostream> #include<string> using namespace std; int main() { string text; cin >> text; cout << text.size(); return 0; }
8th Nov 2019, 12:58 AM
Calviղ
Calviղ - avatar