“Getline CPP” Code-Antworten

Holen Sie sich Linie 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;
}
Collared Lemming

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;
}
pra's play

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

Ähnliche Antworten wie “Getline CPP”

Fragen ähnlich wie “Getline CPP”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen