reading data values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • paultawk
    New Member
    • Oct 2006
    • 10

    reading data values

    If i have a string containing a definite count of numbers(float would be good) separated by spaces and of variable number of digits, let's say three such as "12.3 45 627.8" is there an easy way to read those numbers, and storing them into some predefined variables?
    I was thinking about writing a program that would read the data until a space is encoutered, store it in a predefined variable and then continue, but it seemed rather stupid and too long.
  • arne
    Recognized Expert Contributor
    • Oct 2006
    • 315

    #2
    Originally posted by paultawk
    If i have a string containing a definite count of numbers(float would be good) separated by spaces and of variable number of digits, let's say three such as "12.3 45 627.8" is there an easy way to read those numbers, and storing them into some predefined variables?
    I was thinking about writing a program that would read the data until a space is encoutered, store it in a predefined variable and then continue, but it seemed rather stupid and too long.
    I am not aware of any built-in "split" or even regular expression functionality in C++ (such as most scripting languages provide). My first attempt would have been just as stupid and long as your proposal :-)

    There are additional libraries available, however, such as regex++. Never tried it myself, though ...

    Comment

    Working...