G
Gary Wessle
Hi
I am getting the following output then trying to run the code below.
string does not like what I am doing, why and whats the fix?
thanks
Program received signal SIGSEGV, Segmentation fault.
0x4e34ad7f in std::string::append () from /usr/lib/libstdc++.so.6
#include <string>
#include <iostream>
using namespace std;
class Typ{
public:
string nam;
Typ():nam("mary"){}
};
int main (){
Typ* typ;
string a = "jack";
string f = a.substr(0,1) + "/" + typ->nam;
cout << f << endl;
}
I am getting the following output then trying to run the code below.
string does not like what I am doing, why and whats the fix?
thanks
Program received signal SIGSEGV, Segmentation fault.
0x4e34ad7f in std::string::append () from /usr/lib/libstdc++.so.6
#include <string>
#include <iostream>
using namespace std;
class Typ{
public:
string nam;
Typ():nam("mary"){}
};
int main (){
Typ* typ;
string a = "jack";
string f = a.substr(0,1) + "/" + typ->nam;
cout << f << endl;
}