hey guys im working on a homework problem..im done with 99% of the problem :|however i cnt figure out how to display my output(which is in dollars) using the comma
my output shows >>160000
how would i make it >>160,000
um should i use setprecision???
sorry for not being clear guys...i want to display 160,000 (one-hundred-sixty-thousand)using a comma(,)...
a.dragon>> i am new to c++ so what you saying is use a head file "string" and convert the int variable to string variable ...along with that how would i use this >>std::string<<is this a function??or statement??
int n = 1234567890;
// insert int into stringstream
str << n;
// convert to std::string
string s = str.str();
// now just insert commas in appropriate places
Have you learned anything about converting numbers to strings? Any string manipulation at all? If not, you do not have the knowledge yet. Give it a couple weeks and return to this question. You should have the concepts by then.
thanks again guys..no i havent learned how to convert int to strings ...we just finished the chapter on if statements and teachers output had the comma so i thought maybe there is a function using if statement which allows you to do that..again thanks for the help:)