Mar 2, 2010 at 12:49am UTC
Hi, sorry to bother everyone but I am new at C++ and Have no idea how to do this.
2. Write a program that stores a string containing a full name (First Middle Last) with a single space between any two successive names then it outputs each part of the name in a separate line. For testing purpose, your program MUST use the following name “Henry Louis Aaron” where the output in this case will as given below. Make sure that your program should function properly in case you use any other full name (it should be generic).
First Name: Henry
Middle Name: Louis
Last Name: Aaron
Hint: You need to use various string manipulation functions.
any help is appreciated!
Mar 2, 2010 at 1:08am UTC
Can anyone give me more help. I'm still stumped.
Mar 2, 2010 at 1:55am UTC
1 2 3 4
string first, middle, last;
cout << "Enter you full name: " ;
cin >> first >> middle >> last;
or
1 2 3
string name;
cout << "Enter you full name: " ;
getline (cin, name);
Last edited on Mar 2, 2010 at 1:56am UTC
Mar 2, 2010 at 1:59am UTC
how do i substitute his name in for first, middle and last for the strings to get the output?? im still a little confused..
Mar 2, 2010 at 2:04am UTC
Is that the whole question? it says you need to use various string manipulation functions yet I just don't see the need for any...
ok they say we must use the name given so perhaps they mean concatenation:
1 2 3 4 5 6 7 8 9
string first="Henry" ;
string middle="Louis" ;
string last="Aaron" ;
string name;
name = first + " " + middle + " " + last;
cout << "Name is: " << name << endl;
Last edited on Mar 2, 2010 at 2:04am UTC
Mar 2, 2010 at 2:08am UTC
lol
Last edited on Mar 2, 2010 at 2:24am UTC
Mar 2, 2010 at 2:23am UTC
plzzz help me im so confused.... and theres alot of errors in my code can anyone help?? this is what i got so far.
#include <string>
string first, middle, last;
cout << "Enter you full name: ";
cin >> first >> middle >> last;
string first="Henry";
string middle="Louis";
string last="Aaron";
string name;
name = first + " " + middle + " " + last;
cout << "Name is: " << name << endl;
Mar 2, 2010 at 2:32am UTC
You are trying to declare the same string variables...get rid of "string" before you assign the names to the variables.
Mar 2, 2010 at 2:35am UTC
which string?? can you be more specific please like im really a noob at this so idk what your talking about.
Mar 2, 2010 at 2:42am UTC
try this
edit:Cshark beat me too it... even though his is in C and I can't understand it XD
Last edited on Mar 2, 2010 at 2:47am UTC
Mar 2, 2010 at 2:51am UTC
I need this in C++ language!!!
Last edited on Mar 2, 2010 at 2:51am UTC
Mar 2, 2010 at 2:56am UTC
give me 10 minutes and ill have it done
edit:sorry i don't have time. If i can ill do it in the morning
Last edited on Mar 2, 2010 at 3:04am UTC
Mar 2, 2010 at 3:12am UTC
can anyone else translate this C into C++?? please!