Simple C++ question.

Associate
Joined
18 Feb 2010
Posts
940
I have a set of strings, which are made up of a string and integer.

For example:
Dave5103

This is stored in a char[], actually... there are a lot of them and they are stored in char[][], but that won't affect the solution.

I am looking to pull two bits of data from this, the string, and the integer.
Is this possible? If it helps, I can change the format of these to:
Dave-5103

I'd really appreciate any help with this.
Thanks,
 
As Chris says, you can use strtok to split it into two strings. Then use the atoi function or similar to convert the number into an integer format :).
 
Delimiters are boring. If all names are in the form NameNumber you know when the number starts when the character code is not in the range a-Z. If you want to be too smart for your own good, have a look at using regular expressions (std::tr1)
 
Last edited:
Back
Top Bottom