cannot assign value to std::string

Sory, i cant read my previous reply, so i repost this message.

Hi,

I have problem. Take a look at my code:

struct myStruct{
std::string sTest;
bool bGrab;
};

myStruct *ptrStruct;

//allocate memory
if ((ptrStruct = (myStruct *)malloc(sizeof(myStruct) * (numMasterModel))) == NULL)
exit (-1);

//assign value
ptrStruct->sTest = "just test"; //<-- GENERATE RUNTIME ERROR !
ptrStruct->sTest.assign("just test"); //<-- ALSO GENERATE RUNTIME ERROR !

How to solve this problem? I'm using Microsoft Visual C++. NET 2003. Compiler points to file "iosfwd" when error rises. Please help me

My last question is, what is the difference between this code:

struct myStruct{
std::string sTest;
bool bGrab;
};

and this code:

typedef struct{
std::string sTest;
bool bGrab;
} myStruct;

Any replies appreciate...
what do you mean "you cant read"?
you can find your old posts by clicking on your name.

http://www.cplusplus.com/forum/general/3327/
test
Topic archived. No new replies allowed.