C++: selecting certain lines from a data file
===

I have a datafile of this form:

    B123 1 3 4
    f
    g=1
    B123 3 4 4
    t
    z=2
    .
    .
    .
What I would like to do is to pick the data from the lines starting with B123;

Here's my attempt:

    ifstream in("Data");
    ofstream out("output");
    
    string x1, x2, x3, x4;
    char z[] = "B123";
    const char *p;
    p=x1.c_str();
    
    while(1)
    {
        in>> x1;
        if(!(strcmp(z,p)))
        {
            if((in>>x1>>x2>>x3>>x4))
            {
                 output<<x1<<x2<<x3<<x4;
            }
            else
                 break;
         }
    }
     
    return 0;


But, this way, I only get an empty output file. I want to get:

    B123 1 3 4
    B123 3 4 4

Any suggestions?