include<iostream>
include<conio.h>

using namespace std ;
int main (){

string name;

cin>>name;

cout<<name;

cout<<endl;

getch();

return 0;}

//if u run the prog, and u enter ur first and last name after hitting enter it will show u the first name. My professor asked me to search why this is happening, i know i will find answers here, thank you guys.

Recommended Answers

All 3 Replies

My professor asked me to search why this is happening

"searching" and "asking" is not the same thing. If he wants you to investigate the matter, then you should investigate the matter, not just ask someone else for the answer.

hint hint. it has something to do with cin and strings. try looking up another way of inputting information.

look up difference between cin and cin.getline

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.