Regarding cpp-strings STL

How memory get consumed in strings if we declare a string.

Hi, Raushan, string in STL is a class. Memory consumed for strings is 24 bytes.
You can check it using:

#include < iostream >
#include < string >
using namespace std ;
int main() {
string s = “” ;
cout << sizeof(s) << endl ;
}

Hope this helps :slight_smile:

Hey Raushan,
As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.