txt是这样的:
x234.53716175429 -503.46107102522 -495.76235546239
x227.09524675429 -530.44147402522 -495.69935046239
x240.35633875429 -556.53571902522 -495.66536446239
x270.97325275429 -566.93725502522 -495.68508446239
x301.29620775429 -553.06056002522 -495.75160546239
x310.19765875429 -521.21425102522 -495.82644146239
x300.45068775429 -501.61056702522 -495.85218946239
x274.10408575429 -485.89801302522 -495.84873946239
x248.96131775429 -490.81089602522 -495.80621446239
x248.96377275429 -528.13882502522 -495.73201546239
x264.20327775429 -528.12685202522 -495.75170146239
x281.65088275429 -528.13165402522 -495.77459246239
x269.55070675429 -513.75903602522 -495.78718646239
x269.55559775429 -550.50692902522 -495.71480946239
x308.15720475429 -526.39469802522 -495.81275146239
x308.15733875429 -526.39474602522 -495.81271346239
行数未知我想把第一列的数字(x后面的)读取到数组x中,第二列的到y中,第三列的到z中该怎么操作,同时还想知道每个数组里有多少数

解决方案 »

  1.   

    CStdioFile::ReadString();
    CString::Tokenize()以空格分隔字符串
      

  2.   

    CStdioFile.ReadString
    分析字符串"-"
      

  3.   


    CStdioFile fp;
    fp.Open("kao.txt",CFile::modeRead);
    CString line,str1,str2;
    int pos1,pos2;
    while(!fp.ReadString(line))
    {
       str1=line.Mid(1);//去掉X
       pos1=str1.Find(" ");//查找空格
        x=str1.Left(pos1);
       pos2=str1.Find(" ",pos1+1);//查找空格
       y=str1.Mid(pos1+1,pos2-pos1-1);   z=str1.Mid(pos2+1);
    }
      

  4.   

    数组读取的问题解决了,
    每个数组里有多少数(txt有多少行)怎么解决
      

  5.   

    std::vector
    std::string
    str::string::find std::string::substr
      

  6.   


    用一个变量记录读了多少行,每次ReadString之后加1,就可以啦
      

  7.   

    建议不要用数组,因为数组个数固定,可以考虑
    std::vector