I am writing a simple program to accept a character string. Suppose, the first and last name of the user in an character array and display a welcome message with the full name. But problem arise in the white space. I don't know how to store a multi word sentence in an array. Please help. The following code snippet dose not work.
#include<iostream.h>
int main()
{
char name[50];
cout<<''Enter your full name:'';
cin>>name;
cout<<endl<<''Hello ''<<name<< ''welcome'';
return 0;
}
I believe there is a different iostream.h which is for C which is incompatible with C++. You also need to use std::<function> such as std::cout // makes your programs more compact.
You may use usingnamespace std;
but realize that this will make your programs require much more resources. If you are making small programs this doesn't seem like a big deal but think if you had to compile a giant program. Best to make good habits.
There is probably a more factual/precise discussion on this, please don't take my word for it, find out more at your local library.