刚开始学习vc,下面有一段strcpy中目标字符串(cpConfig)前面加的数字表示什么意思?它不是已经定义为最大了吗?
CString strAccessPath = m_strExePath + "employers.mdb";
int iLen = strAccessPath.GetLength();
char cpConfig[MAX_PATH];

strcpy(cpConfig, "DSN=daliu\0");
strcpy(cpConfig + 10, "DBQ=");
strcpy(cpConfig + 14, strAccessPath);
strcpy(cpConfig + 14 + iLen, "\0");
strcpy(cpConfig + 15 + iLen, "DEFAULTDIR=");
strcpy(cpConfig + 15 + iLen + 11, m_strExePath);
strcpy(cpConfig + 25 + iLen + m_strExePath.GetLength(), "\0\0");

解决方案 »

  1.   

    cpConfig + 10表示从 cpConfig 位置10,开始写入
      

  2.   

    strcpy(cpConfig + 10, "DBQ=");的结果就是cpConfig[10]='D'
    cpConfig[11]='B'
    ...............
    cpConfig此处为数组的起始地址。
      

  3.   

    char cpConfig[MAX_PATH];
    表示分配了一段MAX_PATH大小的内存空间,cpConfig指向空间的首地址
    cpConfig+10指针下移10下,由于是字符数祖,一个里面只能存放一个字符