Tuesday, 15 September 2015

visual c++ - Resolved! C++ : _BLOCK_TYPE_IS_VALID_(pHead->nBlockUse) When adding a converted char array to another char array -



visual c++ - Resolved! C++ : _BLOCK_TYPE_IS_VALID_(pHead->nBlockUse) When adding a converted char array to another char array -

i trying convert std::string char array, , i've tried more few methods..

but keeps throwing error , fails.

http://i.stack.imgur.com/phnbo.png

code:

char text[1000]; void addtexts(string texts){ char *ntext=new char[texts.size()+1]; ntext[texts.size()]=0; memcpy(ntext,texts.c_str(),texts.size()); strcat_s(this->text, strlen(ntext)+1+strlen(this->text), ntext); }

it happens when gets line in code above.

strcat_s(this->text, strlen(ntext)+1+strlen(this->text), ntext);

i have function in code too, 1 works fine

void addtext(char* textc){ strcat_s(this->text, strlen(textc)+1+strlen(this->text), textc); }

the purpose add together string (after converting char*) char array "text", , there no way in case alter "text" char array string.. need maintain is. solution this?

thank you, ray.

c++ visual-c++

No comments:

Post a Comment