I have a string something like this "May-90,June-91,July-92,", how do I separate the character from the integer and store it in an array
Printable View
I have a string something like this "May-90,June-91,July-92,", how do I separate the character from the integer and store it in an array
I am a little bit confused by your question. Can you show us what you wouldl ike the array to hold after you convert it?Quote:
Originally posted by kuk
I have a string something like this "May-90,June-91,July-92,", how do I separate the character from the integer and store it in an array
My string array should look something like this
strarray[] = {"May","June","July"};
and
intarray[] = {90,91,92};
Best solution to this looks like a parsing one. Scroll through the string. At each character use isalpha and isdigit to determine whether it's a number or letter. Once you find a number followed by anthing else, take the value you've stored and put it in the int array. Do the same for letters followed by numbers.Quote:
Originally posted by kuk
My string array should look something like this
strarray[] = {"May","June","July"};
and
intarray[] = {90,91,92};