Editing a string literal - C++ Data Type

C++ examples for Data Type:string

Description

Editing a string literal

Demo Code

#include <iostream>

using namespace std;

namespace/*from ww w.  ja  v  a  2 s.c o m*/
{
    const char* const STRING{ "This is a string" };
    char* EDIT_STRING{ "Attempt to Edit" };
}

int main()
{
    cout << STRING << endl;

    cout << EDIT_STRING << endl;
    EDIT_STRING[0] = 'a';
    cout << EDIT_STRING << endl;

    return 0;
}

Result


Related Tutorials