LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-23-2012, 03:02 AM   #1
GeniusPercy
LQ Newbie
 
Registered: Apr 2012
Posts: 3

Rep: Reputation: Disabled
C++


hi how do i write i script in C++ that takes in a persons " NAME SURNAME & INITIALS" in one line.
then after that i echo out the the " NAME SURNAME $ INITIALS" in this order "SURNAME INITAILS $ NAME".

i tried doing this but did not execute what i want.#include <iostream>
# include <string>

using namespace std;

int main()
{
string names1, names2, names3;
cout << " PLease enter set of 3 names";
getline(cin, names2);

clear;
cout << names1 << endl;

cout << names2 << endl;

cout << names3 << endl;

return 0;
}
 
Old 04-23-2012, 03:20 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,921

Rep: Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319
getline will write data into names2.
How will names1 and names3 contain anything?
 
Old 04-23-2012, 03:25 AM   #3
GeniusPercy
LQ Newbie
 
Registered: Apr 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
sorry i edited that script it suppose to be.

getline(cin, name1)

getline(cin, name2)

getline(cin, name3)
 
Old 04-23-2012, 03:34 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,921

Rep: Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319
and what is the problem with that code?
 
Old 04-23-2012, 03:52 AM   #5
GeniusPercy
LQ Newbie
 
Registered: Apr 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
C++

NVM i have already solved the problem #thanks
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration