Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copying text box entry to char array

Status
Not open for further replies.

raydona

Programmer
May 12, 2005
27
GB
Hi, How do I assign the characters entered into a text box to a c-style character array? I have to do this because the library I'm using contains many functions whose parameters are c-style character arrays. I wish to say something like:
char* x = new char[20];
strcpy(x, textbox->text);
 
Well you should find out the size of textbox->text first by using the strlen() function and allocate that size + 1.
But I'd rather use std::string or std::vector<char> rather than a char array. You can still pass a c-style string to those functions with a std::string (with the c_str() member) or std::vector<char> (by making sure it's nul terminated and passing v[0] to it).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top