![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
|
Strange Output
I get this when I try to do this line "Keith2313Hilary"
std::cout << *a_firstPersonsName << '\t\t' << *a_secondPersonsName << std::endl; #include <iostream>
#include <string>
int main()
{
std::string firstPersonsName;
std::string *a_firstPersonsName = new std::string(firstPersonsName);
std::string secondPersonsName;
std::string *a_secondPersonsName = new std::string(secondPersonsName);
double fp_hourly_pay;
double sp_hourly_pay;
int fp_wrk_hrs_weekly;
int sp_wrk_hrs_weekly;
int fp_hmm;
int sp_hmm;
std::cout << "Enter first person's name to calculate " << std::endl;
std::cin >> *a_firstPersonsName;
std::cout << "How much does " << *a_firstPersonsName << " make an hour? " << std::endl;
std::cin >> fp_hourly_pay;
std::cout << "How many hours does " << *a_firstPersonsName << " work in one week? " << std::endl;
std::cin >> fp_wrk_hrs_weekly;
std::cout << "How many months do you want see how much " << *a_firstPersonsName << std::endl;
std::cout << "will have in that many given months? " << std::endl;
std::cin >> fp_hmm;
//std::cout << *a_firstPersonsName << " will have a total of $" << (((fp_hourly_pay * fp_wrk_hrs_weekly) * 4) * fp_hmm) << '.' << '\n' << std::endl;
std::cout << "Enter second person's name to calculate " << std::endl;
std::cin >> *a_secondPersonsName;
std::cout << "How much does " << *a_secondPersonsName << " make an hour? " << std::endl;
std::cin >> sp_hourly_pay;
std::cout << "How many hours does " << *a_secondPersonsName << " work in one week? " << std::endl;
std::cin >> sp_wrk_hrs_weekly;
std::cout << "How many months do you want see how much " << *a_secondPersonsName << std::endl;
std::cout << "will have in that many given months? " << std::endl;
std::cin >> sp_hmm;
//std::cout << *a_secondPersonsName << " will have a total of $" << (((sp_hourly_pay * sp_wrk_hrs_weekly) * 4) * sp_hmm) << '.' << '\n' << std::endl;
std::cout << *a_firstPersonsName << '\t\t' << *a_secondPersonsName << std::endl;
delete a_firstPersonsName;
delete a_secondPersonsName;
return 0;
} |
|
|
|
|
|
#2 |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 770
Rep Power: 3
![]() |
try putting the \t\t in double quotes. single quotes (') are used for marking single characters, and double quotes (") are for string constants.
Out of curiosity, why do you make a std::string and then use it to make a std::string*? You could just use the std::string and not have to worry about deleting it or dereferencing it, or just use a std::string* with the default constructor and not waste resources on the copy constructor. |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Apr 2006
Location: Calgary, Alberta
Posts: 67
Rep Power: 3
![]() |
Yeah, if you put "\t\t" you will get
Name1 Name2 And I'd make your number of hours doubles, as it is possible to work for half an hour ![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|