CFile f;
CString str;
str="";
int size=f.GetLength();
char buf[1024];//文件大小不同,应该如何设大小
int num=f.Read(buf,size);
buf[num]='\0';
str=buf;

解决方案 »

  1.   

    char * buf = new [nSize+1];
    ....delete [] buf;
      

  2.   

    char * buf=new [nSize+1];//报错
      

  3.   

    char * buf = new char[nSize+1];
      

  4.   

    char * buf = (char*)new [nSize+1];
      

  5.   

    NND,COPY功能不好用。
    char * buf = (char*)new char[nSize+1];
      

  6.   

    CFile f;
    CString str;
    str="";
    int size=f.GetLength();
    char* buf = new char[size];//文件大小不同,应该如何设大小
    int num=f.Read(buf,size);
    str= buf + '\0';你可以试试,我用byte类型是可以通过的,char不知道.
      

  7.   

    用动态数组
    vector或者CStringArray都行
      

  8.   


    void CopyFile(unsigned char *src,unsigned char *des)
    {
    FILE* SrcFile;
    FILE* DesFile;
    unsigned char Data[2048];
    int y=2048;
    unsigned long seek; 
    src[strlen(src)]=NULL;
    des[strlen(des)]=NULL;
    if ((SrcFile=fopen(src,"rb"))==NULL)
    {
    printf ("Open SrcFile(%s) Error\n",src);
    return ;
    }
    if ((DesFile=fopen(des,"wb"))==NULL)
    {
    printf ("Open DesFile(%s) Error\n",des);
    return ;
    }
    while(y==2048)
    {
    y=fread(Data, sizeof(char), 2048, SrcFile);
    fwrite(Data, sizeof(char), y, DesFile);
    }
    fclose(SrcFile);
    fclose(DesFile);
    }