Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Remove double from string and store in an array

  • 13-09-2009 05:07PM
    #1
    Registered Users, Registered Users 2 Posts: 46


    Hi folks,
    I have a string that will be different each time but follow the form of
    -3.33,-46.53,37.39,26.55,97.11,68.46,-32.46,-5.89,-62.89,-7.9,
    and i want to remove each number and store as an double in an array.
    even pseudocode would be great i'm drawing a blank.
    Cheers


Comments

  • Registered Users, Registered Users 2 Posts: 21,278 ✭✭✭✭Eoin


    You mean something like this?
    string input = "-3.33,-46.53,37.39,26.55,97.11,68.46,-32.46,-5.89,-62.89,-7.9,";
    
    string arrInput[] = input.split(",");
    
    double arrOutput[] = new array of doubles;
    
    for (int i = 0; i < arrInput.length; i++)
    {
        double myNum = ConvertToDouble(arrInput[i]);
        arrOutput[i] = myNum;
    }
    


  • Registered Users, Registered Users 2 Posts: 21,278 ✭✭✭✭Eoin


    Well?


  • Registered Users, Registered Users 2 Posts: 46 neonic75


    Hi Eoin,
    Sorry you'll have to pardon my ignorance for not posting back, i've been flat out. That worked perfectly. thanks.
    Cheers


Advertisement