利用CStdioFile读取下面这个文件,我该如何才能读取下面的这些16进制数据到一个数组里呢?static GUI_CONST_STORAGE GUI_COLOR Colorslena512back24[] = {
     0x000000,0x000024,0x000048,0x00006D
    ,0x000091,0x0000B6,0x0000DA,0x0000FF
    ,0x002400,0x002424,0x002448,0x00246D
    ,0x002491,0x0024B6,0x0024DA,0x0024FF
    ,0x004800,0x004824,0x004848,0x00486D
    ,0x004891,0x0048B6,0x0048DA,0x0048FF
}

解决方案 »

  1.   

    static GUI_CONST_STORAGE GUI_COLOR Colorslena512back24[] = {
         0x000000,0x000024,0x000048,0x00006D
        ,0x000091,0x0000B6,0x0000DA,0x0000FF
        ,0x002400,0x002424,0x002448,0x00246D
        ,0x002491,0x0024B6,0x0024DA,0x0024FF
        ,0x004800,0x004824,0x004848,0x00486D
        ,0x004891,0x0048B6,0x0048DA,0x0048FF
    }
    这个内容都是文件中的?包括static ...?
      

  2.   

    好办阿。CStdioFile支持逐行读取。你先逐行读取,然后对每行的信息用逗号拆分就可以了。
      

  3.   

    空格?读取的字符串,用TrimLeft和TrimRight过滤空格就可以了。
      

  4.   

    CStdioFile file; if( !file.Open("c:\\1.c", CFile::modeRead) ) { AfxMessageBox("can not open file!"); return; }
    CString strLine;
    CStringArray arrTemp;
    arrTemp.RemoveAll(); while( file.ReadString(strLine) ) {
    if(strLine.Find(',') == -1)
    continue;
    strLine.TrimLeft();
    strLine.TrimRigth(); char *ss=strLine.GetBufferSetLength(strLine.GetLength());  char *p; for ( p=strtok(ss, ","); p!=NULL; p=strtok(NULL, ",") ) {
    arrTemp.Add(*p); } } file.Close();////////////////////////////////
    then you can use arrTemp like this:for(int i=0; i<arrTemp.GetSize(); i++)
    {
    CString str;
    str += arrTemp[i]+"\r\n";   
    }
    AfxMessageBox(arrTemp[i]);
      

  5.   

    modified : CString strTemp; for ( p=strtok(ss, ","); p!=NULL; p=strtok(NULL, ",") ) {
    strTemp = *p;
    strTemp.TrimLeft();
    strTemp.TrimRigth();
    if(strTemp.IsEmpty())
    continue;
    arrTemp.Add(*p); }