C++ String Read from Standard Input Question

Introduction

Write a program that accepts the first and the last name from the standard input using the std::getline function.

Store the input in a single string called fullname.

Print out the string.

You can use the following code structure.

#include <iostream> 

int main() 
{ 
    //your code here
} 



#include <iostream> 
#include <string> 

int main() 
{ 
    std::string fullname; 
    std::cout << "Please enter the first and the last name: "; 
    std::getline(std::cin, fullname); 
    std::cout << "Your name is: " << fullname; 
} 



PreviousNext

Related