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;
}

 

posted @ 2014-07-30 13:16  2014acm  阅读(1671)  评论(0编辑  收藏  举报