Game Development Community

Vector to *char

by Luigi Rosso · in Technical Issues · 01/31/2002 (7:11 pm) · 5 replies

Is there any cast I can do to get a vector (array) of characters into a char pointer?

Would the dSprintf function work?

Thanks!

#1
02/01/2002 (12:54 am)
Do you mean an ordinary C array (like "char array[20];")? In this case 'array' already is a char*.
#2
02/01/2002 (2:06 am)
No it's an actual vector type. You can .resize() and .len()

It's its own class. You can declare a vector of characters, integers, floats...whatever (same way like int myint[10] but those aren't resizeable).
#3
02/01/2002 (2:18 am)
Then you have to make the conversion yourself, maybe by iterating through the vector to build a string out of it.
#4
02/01/2002 (3:09 am)
I found a solution here it is if anyone ever has such a question again:

char *string = &(*myCharVector.begin());
#5
02/02/2002 (3:34 am)
oh
:)