<p>I need to use C++ to read in text with spaces, followed by a numeric value.</p>

<p>For example, data that looks like:</p>

<pre><code>text1
1.0
text two 
2.1
text2 again
3.1
</code></pre>

<p>can't be read in with 2 <code>"infile &gt;&gt;"</code> statements. I'm not having any luck with <code>getline</code> 
either. I ultimately want to populate a <code>struct</code> with these 2 data elements. Any ideas?</p>

If you can be sure that your input is well-formed, you can try something like this sample:
```
```
#include <iostream>
#include <sstream>

int main()
{
    std::istringstream iss("text1 1.0 text two 2.1 text2 again 3.1");

    for ( ;; )
    {
        double x;
        if ( iss >> x )
        {
            std::cout << x << std::endl;
        }
        else
        {
            iss.clear();
            std::string junk;
            if ( !(iss >> junk) )
                break;
        }
    }
}
```
```
If you do have to validate input (instead of just trying to parse anything looking like a double from it), you'll have to write some kind of parser, which is not hard but boring.