Horje
get line C++ Code Example
get line C++
// extract to string
#include <iostream>
#include <string>

int main ()
{
  std::string name;

  std::cout << "Please, enter your full name: ";
  std::getline (std::cin,name);
  std::cout << "Hello, " << name << "!\n";

  return 0;
}
getline cpp
//getline allows for multi word input including spaces ex. "Jim Barens"
#include <iostream>
#include <string>

int main() 
{
  string namePerson{};     // creating string
  getline(cin, namePerson);// using getline for user input
  std::cout << namePerson; // output string namePerson
}
getline in c++

#include<bits/stdc++.h>
using namespace std;
#define e  "\n"

int main()
{
    string food, name;
    int age;

    getline(cin,name);// for space
    cin>>age;
    cin.ignore();// to ignore the newline character
    getline(cin,food);
    cout<<name<<" "<<age<<" "<<food<<e;

    return 0;
}




Cpp

Related
max of a vector c++ Code Example max of a vector c++ Code Example
get thread id c++ Code Example get thread id c++ Code Example
change integer to string c++ Code Example change integer to string c++ Code Example
convert decimal to binary c++ Code Example convert decimal to binary c++ Code Example
initialize 2D vector Code Example initialize 2D vector Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8