I am trying to execute following code which is giving me segmentation fault. What error I am doing or am I missing any part ? can this code be implemented in some other way?
Code:
#include <iostream>
#include "string.h"
using namespace std;
struct A {
char* a;
};
int main()
{
struct A *x;
x->a = "soumya";
char* str = "soumya";
cout<<str<<endl<<(char*)x->a<<endl;
// if(strcmp(x->a,str)!=0)
// {
// cout<<"not same"<<endl;
// }
return 0;
}