Hi, I wanted to pass an input to a char* then pass it to a class member.
but before i even get to the class member, i got stuck in the char* itself.
after i compile, it's ok.Code:#include <iostream> using namespace::std; class CTest { public: char *name; }; CTest Test; char *gName = ""; int main() { cout<<"Enter Name: "; cin>>gName; //<--here's the error Test.name = gName; return 0; }
but once i run it.
then it breaks and popup a message saying:
then opens a page on the "istream" file.Unhandled exception at 0x104f01be (msvcp80d.dll) in test.exe: 0xC0000005: Access violation writing location 0x0041664b.
any leads to solve this?
I thought char* was able to store as string?