Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Remove double from string and store in an array

Options
  • 13-09-2009 5:07pm
    #1
    Registered Users 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 Posts: 21,257 ✭✭✭✭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 Posts: 21,257 ✭✭✭✭Eoin


    Well?


  • Registered Users 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