+ 1

[SOLVED] Hi Guys, I need to run a program on C++ that prints my first name and last name.

My last name also needs to be preceded by as many hyphens as character that I have in my first name. An example would be: Robert ------ Smith. Thanks in advance.

10th Sep 2020, 9:57 PM
Kristo Papa
Kristo Papa - avatar
3 Respostas
+ 2
Kristo Papa Check your 5th cout line after cout<<"Your name preceded by hyphens is :"<<fname<<""<<lname<<" "<<------<<""endl ; You use wrong endl and hyphens your hyphen should be in double quotes and before last endl you have to write (<<) means <<endl ; See this #include<iostream> #include<string> using namespace std; int main() { char fname[30], lname [30]; cout << "\n\n Print your name:\n"; cout << "-----------------------------------------------------------\n"; cout << " Input First Name: "; cin >> fname; cout << " \nInput Last Name: "; cin >> lname; cout << " \nYour name preceded by hyphens is: "<< fname << " "<<lname << " " <<"------ "<< "" <<endl; cout << endl; return 0; }
11th Sep 2020, 1:15 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 8
It'd be friendlier to the eyes Kristo Papa if you linked your code from Code-Playground.
11th Sep 2020, 2:41 AM
Fox
Fox - avatar
+ 4
Hello Kristo Papa Please don't ask for codes here. Please show us your attempt, so we can help you.
10th Sep 2020, 9:59 PM
Denise Roßberg
Denise Roßberg - avatar