zoukankan      html  css  js  c++  java
  • C++ 中的“读一行” getline(cin , s) cin.getline(s, 100)

    #include<string>
    using namespace std;
    int main(int argc, char *argv[])
    { 
      string s;
      cin>>s;
      cout<<s<<endl;;
        
        return 0;
    }
    View Code

    #include <iostream>

    #include<string>

    using namespace std;

    int main(int argc, char *argv[])

    {      

     string s;

      cin>>s;

      cout<<s<<endl;

       return 0;

    }

    ****************************************************************************************************************************

    #include <iostream>
    
    #include<string>
    
    using namespace std;
    
     
    
    int main(int argc, char *argv[])
    
    {   
    
      string s;
    
         getline( cin, s)  ;
    
            cout<<s<<endl;
    
        return 0; }
    
     
    View Code

    #include <iostream>

    #include<string>

    using namespace std;

    int main(int argc, char *argv[])

    {  

      string s;

         getline( cin, s)  ;

            cout<<s<<endl;

        return 0; }

    #include <iostream>
    #include<string>
    using namespace std;
    int main(int argc, char *argv[])
    {
        string s;
        while (getline(cin,s))
            cout<<s<<endl;
    
        return 0;
    }
    View Code

    #include <iostream>

    #include<string>

    using namespace std;

    int main(int argc, char *argv[])

    {   

      string s;

        while (  getline( cin, s)  )

            cout<<s<<endl;

        return 0; }

     

    *********************************************************************************************************

    #include <iostream>
    #include <string>
    using namespace std;
    main ()
    {
             char s[100];
             cin.getline (s, 100);
             cout << name <<endl;
    }

  • 相关阅读:
    .Proto 文件转换成.cs文件
    C# 委托和事件
    C# 对word (03、07)的相关操作
    程序中记录日志的封装类
    压缩文件程.ZIP
    xml和对象直接的序列化和反序列化
    C#判断两个日期是否在同一周,某日期是本月的第几周
    vs2008 C# 单元测试
    解压缩.zip文件
    记录一次曲折的维护-重构过程
  • 原文地址:https://www.cnblogs.com/2014acm/p/3877793.html
Copyright © 2011-2022 走看看