Im triying to compile and execute this small c++ code using g++ 5.1, it's compiled fine, when i execute it on linux
i get this error message : "Segmentation fault (core dumped)
".
But the same code run correctly on osx but not on linux :
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
struct node {
std::string data;
};
int main() {
struct node * node = (struct node * )
malloc(sizeof(struct node));
node->data.assign("string");
// node->data = "string" --> same issue
return 0;
}
i tried a simple assigne (node->data = "string"), but i got the same problem Any help please !