当前位置:首页 » 多媒体相关

简单问题


//main.cpp  
  //~  
   
  #include   "iostream.h"  
  #include   "string.h"  
   
  using   namespace   std;  
   
  int   main()  
  {  
  string   user_name;  
  cin   >>   user_name;  
  cout   <<   end  
    <<   user_name;  
  return   0;  
  }  
   
  编译时出现如下错误:  
  --------------------configuration:   cin   -   win32   debug--------------------  
  compiling...  
  cin.cpp  
  f:\源代码\c\cin.cpp(7)   :   error   c2871:   std   :   does   not   exist   or   is   not   a   namespace  
  f:\源代码\c\cin.cpp(11)   :   error   c2065:   string   :   undeclared   identifier  
  f:\源代码\c\cin.cpp(11)   :   error   c2146:   syntax   error   :   missing   ;   before   identifier   user_name  
  f:\源代码\c\cin.cpp(11)   :   error   c2065:   user_name   :   undeclared   identifier  
  f:\源代码\c\cin.cpp(14)   :   error   c2065:   end   :   undeclared   identifier  
  error   executing   cl.exe.  
   
  cin.exe   -   5   error(s),   0   warning(s)

推荐阅读

  • 不甘人后 台电“NANO”C133+狂降百元 [详细内容]
  • 26万色真彩MP3 索尼P13降百元现699 [详细内容]
  • 宽带门户有多远 “青娱乐”进入你的生活 [详细内容]
  • 闪电价格战!昂达VX系列全线降价 [详细内容]
  • 家用机新的选择 三洋VPC-S60露面 [详细内容]
  • 首届“新消费·影响力品牌”推广活动进入入围阶段 [详细内容]
  • KG90的两个小缺陷 [详细内容]
  • 网友回答:
    网友:emailtan

    应该是这样的:  
      #include   "iostream"  
      #include   "string"  
       
      using   namespace   std;  
       
      int   main()  
      {  
      string   user_name;  
      cin   >>   user_name;  
      cout   <<   endl  
        <<   user_name;  
      return   0;  
      }

    网友:emailtan

    用using   namesapce   std后就不用在头文件上加.h了.

    网友:honghuer

    //main.cpp  
      //~  
       
      #include   <iostream>  
      #include   <string>  
       
      using   namespace   std;  
       
      int   main()  
      {  
      string   user_name;  
      cin   >>   user_name;  
      cout   <<   endl<<   user_name   <<endl;  
      return   0;  
      }  
     

    网友:huanbaobao

    //main.cpp  
      //~  
       
      #include   "iostream"  
      #include   "string"  
      using   namespace   std;  
       
      int   main()  
      {  
      string   user_name;  
      cin   >>   user_name;  
      cout   <<   endl  
      <<   user_name;  
      return   0;}  
     

    网友:fanzai

    同意楼上,这是c语言为了兼容以前的程序而作的修改。  
      一般情况下加不加.h是一模一样的,但是iostream就偏有这么个古怪的个性。

    网友:bluebohe

    wangweintk(枫杨)   建议你多研究一下标准c++;你这不是误人子弟嘛  
      这样试一下也许会好一些  
      //main.cpp  
      //~  
       
      #include   "iostream.h"  
      #include   "string"  
       
      using   namespace   std;  
       
      int   main()  
      {  
      string   user_name;  
      cin   >>   user_name;  
      cout   <<   endl<<   user_name;  
      return   0;  
      }  
     

    .

    讨论区

    Login