How to convert a vector<char> to a const char array?

Hello I'm having troubles doing conversions of vectors and chars :(.

Heres my vector:

vector<char> file_data;

Heres my const char :

const char file_char;

How do I convert it??.
Last edited on
const char file_char; is not an array

If you mean a pointer to an array const char* file_char;

You can use & on the first element in the vector to get a pointer to the internal array.
const char* file_char = &file_data[0];

In C++11 You can also use the data() member function.
const char* file_char = file_data.data();
I ment an actual conversion :) of a vector char to a const char

Heres my vector:

vector<char> file_data;

Heres my const char :

const char file_char;
Last edited on
Topic archived. No new replies allowed.