Fábio
Fábio

Reputation: 3489

Proper way to obtain a std:string from a Pro*C/C++ VARCHAR

What is the proper way of getting a std:string out of a Pro*C/C++ VARCHAR?

VARCHAR some_column[10];

std::string x(reinterpret_cast<char const*>(some_column.arr), some_column.len);
std::string y((char const*) some_column.arr, some_column.len);

Upvotes: -2

Views: 167

Answers (1)

EvilTeach
EvilTeach

Reputation: 28882

Basically you can't.

Read it into a character array which is big enough to hold the value. Add one additional character to the array size, and initialize it to 0, so that you have a c string.

After loading it, into the character buffer, assign it to the string.

Upvotes: 0

Related Questions