mercredi 17 novembre 2021

Difference between std::string and const char*?

What's the difference between std::string and const char*? consider following example

#include <iostream>

int main()
{
    const char* myName1{ "Alex" }; 
    std::cout << myName1 << '\n';
    char myName2[]{ "Alex" }; 
    std::cout << myName2 << '\n';
    return 0;
}

are they the same?

Aucun commentaire:

Enregistrer un commentaire