CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: string to array

  1. #1
    Join Date
    Jun 2000
    Location
    USA
    Posts
    2

    Post string to array

    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

  2. #2
    Join Date
    May 2002
    Location
    Atlanta,GA
    Posts
    262

    Re: string to array

    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
    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?
    Jared

  3. #3
    Join Date
    Jun 2000
    Location
    USA
    Posts
    2

    string to array

    My string array should look something like this

    strarray[] = {"May","June","July"};

    and

    intarray[] = {90,91,92};

  4. #4
    Join Date
    May 2002
    Location
    Atlanta,GA
    Posts
    262

    Re: string to array

    Originally posted by kuk
    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.
    Jared

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured