I have an input file like this:
   Virtual   (A) (A) (A) (A) (A) (A) (A) (A) (A) (A) (A) (A)
The electronic state is 1-A.
Alpha  occ. eigenvalues --   -0.26426  -0.26166  -0.25915  -0.25885  
Alpha  occ. eigenvalues --   -0.25284  -0.25172  -0.24273  -0.23559  
Alpha  occ. eigenvalues --   -0.20078  -0.19615  -0.17676  -0.10810  
Alpha virt. eigenvalues --   -0.07062  -0.06520  -0.05969  -0.01767  
Alpha virt. eigenvalues --   -0.01604  -0.00951  -0.00428   0.00041  
I would like to export the first line obtaining first 11 characters " Alpha virt.". How should I do? I code by C++ language as below code, but it cant finish while loop functio. I dont know why, I am a fresher. Please help me. Thank you so much. My C++ code:
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>
#define FILENAME "filelog.txt"
using namespace std;
int main(void) {
    char* line_buf = NULL;
    size_t line_buf_size = 0;
    int line_count = 0;
    string s;
    std::string dongsosanh = " Alpha virt.";
    FILE* fp = fopen(FILENAME, "r");
    getline(&line_buf, &line_buf_size, fp);
    std::string STRR(line_buf, 11);
    do {
        line_count++;
        getline(&line_buf, &line_buf_size, fp);
    } while(STRR.compare(dongsosanh) != 0);
    std::cout << STRR << endl;
    return 0;
}
Thank you so much.
 
     
     
    