This program is compiled and run but showing error: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
#include<iostream>
using namespace std;
struct person{
 char* name;
 char* lastName;
 int age;
};
void show(person temp){
 cout << temp.name << " " << temp.lastName << " age is: " << temp.age;
}
int main(){
// decaring a person    
 person p;
 p.name = "Jayant";
 p.lastName = "Sharma";
 p.age = 18;
//reassigning of p 'name'
 p.name = "Kartik";
 show(p);
 return 0;
}
// output => Kartik age is: 18
But when I declare variables using const compiler not shows an error and reassigning is also done
struct person{
    const char* name;
    const char* lastName;
    int age;
};
reassigning the name 'Kartik' to the same const variable 'name' is done without an error.
 
    