std::string to char[] with a twist

R

ruffiano

Hello,

I need your expertise to perform a conversion.

I need to convert a std::string to a char[32]. However, in the
conversion, I need to get rid of the '/0' character. The initial string
represents a 256 bit (32 byte) numeric value. Therefore, the resulting
char[32] should not contain '/0'.

If you have any suggestions, please let me know.
 
F

fungus

ruffiano said:
I need to convert a std::string to a char[32]. However, in the
conversion, I need to get rid of the '/0' character. The initial string
represents a 256 bit (32 byte) numeric value. Therefore, the resulting
char[32] should not contain '/0'.

If you have any suggestions, please let me know.

Usually you have to make extra effort to actually
copy the '\0', not the other way around.



--
<\___/>
/ O O \
\_____/ FTB. For email, remove my socks.

In science it often happens that scientists say, 'You know
that's a really good argument; my position is mistaken,'
and then they actually change their minds and you never
hear that old view from them again. They really do it.
It doesn't happen as often as it should, because scientists
are human and change is sometimes painful. But it happens
every day. I cannot recall the last time something like
that happened in politics or religion.

- Carl Sagan, 1987 CSICOP keynote address
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,122
Latest member
VinayKumarNevatia_
Top