e:\code\test\test.cpp(6) : fatal error C1083: 无法打开包含文件:“iostream.h”: No such file or directory很简单的一个测试程序 另外 我想查一下VC的STRCPY这些函数的源代码 怎么找不到string.cpp这个文件

解决方案 »

  1.   

    1. #include <iostream> 
    2005遵循了最新的C++标准,把C++头文件的后面的.h扩展名都去掉了2. CRT 函数的代码都在$(YOUR_2005_DIR)\VC\crt\src下面。你所说的strcpy的代码在$(YOUR_2005_DIR)\VC\crt\src\intel\strcat.asm中。
      

  2.   

    是2003 不是2005 
    去掉.h后 
    e:\code\test\test.cpp(44) : error C2065: “cout” : 未声明的标识符
    e:\code\test\test.cpp(44) : error C2065: “endl” : 未声明的标识符
    e:\code\test\test.cpp(46) : error C3861: “cout”: 即使使用参数相关的查找,也未找到标识符
    e:\code\test\test.cpp(46) : error C3861: “endl”: 即使使用参数相关的查找,也未找到标识符
      

  3.   

    这么一个简单的程序 执行时却出错 VC6里是正常的 
    void Reverse(char *str)
    {
    char c;
    char *p = str;
    char *s = str;
    int n = 0, m = 0; while(*p != 0) {
    n++;
    p++;
    }
    p--;
    n = (n-1)/2;

    while( m <= n )
    {
    c = *(s+m);
    *(s+m) = *(p-m);
    *(p-m) = c;
    m++;
    }
    }int main(int argc, char* argv[])
    {
    char *p = "abcdefg;";
    cout << p << endl;
    Reverse(p);
    cout << p << endl;
    }
      

  4.   

    char *p = "abcdefg;";是常量,是只读不可修改的,修改的话会报Access Violation。应该make一份copy再调你的Reverse函数。
    Main应该这样写:
    int main(int argc, char* argv[])
    {
    char *p = strdup("abcdefg;"); cout << p << endl;
    Reverse(p);
    cout << p << endl;         free(p);
    }我手头没有2003,但想来应该是2003和2005在对字符串常量的处理方式不同而造成的。其实2005这么做是正确的,可以发现更多问题。
      

  5.   

    Sorry,看错了,你说的是VC6上不出错,不是2003,不过道理是一样的
      

  6.   

    果然
    不过有个问题  char *p = "abcdefg;"; 这是常量
    char *s = _strdup(p);  这却成了可变的  不都是 char *