我想做一个矩阵运算,是550x35000的矩阵,我使用的是CArray类定义的二维矩阵来进行计算,但是程序也不出错,也不出数据,内存使用104MB,问朋友说是数组太大了,要我使用动态数组写磁盘,哎我也不会呀
请问各位高手又没有解决的办法?

解决方案 »

  1.   

    void LoadIndex(const char *IndexFilePath)
    {
    struct ChCharNode *ptr, *ptr1;
    struct FileChar *pfc, *pfc1; FILE *indexfile0; /* 索引文件指针 */
    int ChCount; /* 汉字个数 */
    int FCount;  /* 文件个数 */
    int PCount;  /*位置个数 */

    char FilePath[100];
    //unsigned short Ch, t; /* 汉字 */
    char *term;
    int i, j;
    CString Ch=_T("");
    indexfile0 = fopen(IndexFilePath, "r");/*here has some question*/
    if(indexfile0==NULL)
    {
    AfxMessageBox("文件不能打开!");
    }
    else
    {
    fscanf(indexfile0, "短语个数:%d\n", &ChCount);

    for (i = 0; i < ChCount; i++)
    {

    fscanf(indexfile0, "%s\n",Ch);
    if( Ch == "" )
    {
    fscanf(indexfile0, "%s\n",Ch);
    }
    term=new char[Ch.GetLength()];
    strcpy(term,(LPCTSTR)Ch);///问题就出在这里当加在第18602个词时就出错了 fscanf(indexfile0, "文件个数:%d\n", &FCount); for (j = 0; j < FCount; j++)
    {
    fscanf(indexfile0, "%s\n", FilePath);
    fscanf(indexfile0, "出现次数:%d\n", &PCount);
    if(!ChIndex)
    {
    ChIndex=new struct ChCharNode;
    ChIndex->ChChar=term; ChIndex->FCList=new struct FileChar;
    ChIndex->FCList->FilePath=new char[strlen(FilePath)+1];
    strcpy(ChIndex->FCList->FilePath,FilePath);
    ChIndex->FCList->CharacterCount=PCount; ChIndex->FCList->next=NULL;
    ChIndex->next=NULL;
    }
    else
    {
    for (ptr=ChIndex,ptr1=ChIndex;ptr;ptr1=ptr,ptr=ptr->next)
    if(ptr->ChChar==Ch)
    {
    for(pfc=ptr->FCList,pfc1=ptr->FCList;pfc;pfc1=pfc,pfc=pfc->next)
    ;
    if(!pfc)
    {
    pfc1->next=new struct FileChar;
    pfc1=pfc1->next;
    pfc1->FilePath=new char[strlen(FilePath)+1];
    strcpy(pfc1->FilePath,FilePath);
    pfc1->CharacterCount=PCount;
    pfc1->next=NULL;
    }
    break;
    }
    if(!ptr)
    {
    ptr1->next=new struct ChCharNode;
    ptr1=ptr1->next;
    ptr1->ChChar=term;
    ptr1->FCList=new struct FileChar;
    ptr1->FCList->FilePath=new char[strlen(FilePath)+1];
    strcpy(ptr1->FCList->FilePath,FilePath);
    ptr1->FCList->CharacterCount=PCount;
    ptr1->FCList->next=NULL;
    ptr1->next=NULL;
    }
    } //delete term;

    }
    fscanf(indexfile0, "--------------------------\n");
    }

    fclose(indexfile0);
    }
    }