Double to String

Got confused with atof, is there anyone someone can give me the missing line

1
2
3
4
double I,
String amthankful,
//assuming i've already error checked the above
//need a line to convert I to amthankful 
What is class String with capital S ?
one I made, it is exactly the same as the class string I just made it so I could be corrected
What do you mean by exactly the same? You mean it is a typedef? I seriously doubt that you made your own String class from the ground up which is exactly the same as std::string.
I'm pretty sure he's just joking that the capitalization error is just a typographical error in this post and not actually part of his code. I'm making that assumption because it's left justified (which is what happens when you type it in rather than copypaste), uses commas instead of semicolons and, oh yes, uses the sentence "I am thankful" for variable names.

I'm guessing that the solution involves converting your C++ string to a C string with this page: http://www.cplusplus.com/reference/string/string/c_str/

and then using atof or strtod on it:
http://www.cplusplus.com/reference/clibrary/cstdlib/atof/
http://www.cplusplus.com/reference/clibrary/cstdlib/strtod/


-OR-

You could read this link:
http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.2
No, I think you should just make your own function to do it. i've done and it's possible, even easy. just divide by 10s, ask if you don't get it and ill explain.
I'll link this anyways: http://www.cplusplus.com/articles/numb_to_text/
If your String class is not std::string, you'll have to do some extra stuff
Topic archived. No new replies allowed.