Original Post
🔒 Locked
string conversion
Advertisement
Thanks for the reply, but I am not sure how to use the std::string::c_str().
I have an array of (string) words, and each word is referenced by words[n]. Using atof(words[n]) doesn''t work. How can I use the above to cast the string into a char[].
Sorry, if I appear dum, I am just getting back into c/c++ after a good few years of and its like learning all over again. the old saying is true - "If you don''t use it, you lose it!"
Many thanks again
Scott
I have an array of (string) words, and each word is referenced by words[n]. Using atof(words[n]) doesn''t work. How can I use the above to cast the string into a char[].
Sorry, if I appear dum, I am just getting back into c/c++ after a good few years of and its like learning all over again. the old saying is true - "If you don''t use it, you lose it!"
Many thanks again
Scott
float nums[10];
for (int n = 0; n < 10; n++) {
nums[n] = atof(words[n].c_str());
}
Get the idea?
_____________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement