There is an arbitrary string of no more than 25 characters. For example “wo1fram”
How to convert it to char array ?
So that later you can work with char as with a full-fledged array of characters, terminated by a null character.
Answer 1, authority 100%
There are two solutions, you see.
One thing – if you just need to read this line, or there, change a couple of characters in it – but do not change its size (so all sorts of
strcpy are canceled) – then you can use the functions
c_str () and
data () . I highly recommend that you carefully read the descriptions, and most importantly, the restrictions imposed by these functions.
And another thing – if you need to work with it as a C-style string with all the possibilities – then just copy it into an array, like
char buf ; strcpy (buf, s.c_str ());
char * buf = strdup (s);
Something like this.