#include <stdio.h>
#include <iostream.h>
int main ()
{ string word;

while (cin>>word )
cout<<"word read is: " <<word; cout<<"end";
return 0;
}编译不通过(书上copy) 
vc 里有string 吗?如果没有string.h 有什么用?

解决方案 »

  1.   

    采用STL吧,这样就可以了
    #include<string>
    #include <iostream>
    using namespace std;
    int main ()
    {

    string word;



    while (cin>>word )
    cout<<"word read is: " <<word;

    cout<<"end";
    return 0;
    }
      

  2.   

    不好意识,能执行了。
    但using namespace std;不明白
    请指教
      

  3.   

    你用的string,cout等都是C++标准库的一部分,他们全部都包含在一个叫std的名字空间里。
    using namespace std;让他们对你可见,否则你不能调用他们
      

  4.   

    你也可以试试这样,用using namespace std::string;
    这样string对你是可见的,cout不可见
    标准C++库的头文件是没有扩展名的,如
    #include <iostream>
    #include <string>如果你用
    #include <iostream.h>
    那就不用写 using语句了