arrays...

hi .. hope you will be fine and having good health as well.. would please sort something out for me,, I need your kind help..

Below is the code of a program,, it ask the user for information..

This is the output (Please, enter your first name: John
Hello, John!)


First Question:???
when I insert my full name JUNAID KHAN, so it just shows JUANID so can you please tell me why is this so and what th solution for that???

2ND Question:
how to write the same programme using functions?


#include<iostream>

using namespace std;
int main()
{
char question[]= "Please Enter your name : ? ";
char greeting[]= "Hello " ;
char yourname[200];


cout<< question;
cin>> yourname;
cout<< greeting << yourname;
return 0;
}


use cin.getline (yourname,200);
Your line cin>> yourname; reads only the first part of the string (ends at the space)
Last edited on
Topic archived. No new replies allowed.