You are making a char* with no elements, and then trying to assign data to it. This means you will be going out of bounds of the array. I would suggest using an std::string instead if you can. Also, you defined it as const, which means you cannot modify it, and you will get a segfault when writing to the read-only memory.