坐标X   坐标Y   2  2
12.0    20.0
12.0    20.020.0    12.0
20.0    12.0其中 2 2度为整数值
12.0读为double型

解决方案 »

  1.   

    fstream finput;
    double m;
    finput.open(你的文件,‘r’);
    while(input>>m)
     cout<<m<<endl;
    貌似这样,我也弄过一个这样的 CFileDialog myopen(TRUE,NULL,apppath,OFN_NOCHANGEDIR|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"table file|*.tbl||",NULL);
    if (myopen.DoModal()==IDOK)
    {
    fstream finput;
    UpdateData();
    m_choosfile=myopen.GetFileName();
    UpdateData(FALSE);
    finput.open(myopen.GetPathName());
    double m;
    int i=0;
    int j=0; //=========================
    //read rows,col from txt  ||
    //=========================

    finput>>row;
    finput>>col; //=========================================
    //Create the array dymaticly                ||
    //========================================= checktable=new double*[row];
    for (int tk=0;tk<row;tk++)
    {
    checktable[tk]=new double[col];
    } //================================================
    //write the data to array from txt file;     ||
    //================================================ while (finput>>m)
    {
    if (j>(col-1))
    {
    j=0;
    i++;
    if (i>(row-1))
    {
    finput.close();
    return;
    }
    checktable[i][j]=m;
    } else
    {
    checktable[i][j]=m;
    }
    我的txt格式如下:
    9
    9
    0 0.1 0.2 0.3 0.5 0.75 1.0 2.0 10.0
    0.01 0.428 0.368 0.349 0.331 0.320 0.318 0.315 0.310
    0.02 0.600 0.502 0.470 0.440 0.428 0.420 0.411 0.404
    0.03 0.729 0.599 0.558 0.520 0.501 0.492 0.483 0.473
    0.05 0.931 0.756 0.694 0.644 0.618 0.606 0.589 0.580
    0.07 1.075 0.873 0.801 0.742 0.711 0.697 0.672 0.650
    0.10 1.252 1.027 0.935 0.857 0.817 0.801 0.790 0.739
    0.15 1.518 1.235 1.109 1.021 0.965 0.938 0.895 0.872
    0.20 1.745 1.395 1.254 1.140 1.080 1.045 1.000 0.969