Link.
Actually, I didn't know myself string had this method. I have always used += for appending.
Code:std::string numericString; for(int i = 0; i < 5; i++){ numericString += '1'; }
Link.
Actually, I didn't know myself string had this method. I have always used += for appending.
Code:std::string numericString; for(int i = 0; i < 5; i++){ numericString += '1'; }
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
Last edited by Masterx; 01-23-2009 at 11:36 AM.
Highlight Your Codes
The Boost C++ Libraries (online Reference)
Bill Bryson"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
What do you mean? I merely provided an example of how to use an index based for loop to iterate over the characters of a string. You would need to combine this with std::string's push_back(), or whatever method you wish to use to append to the destination string.Originally Posted by Masterx
You would not need to fully qualify std::string::size_type, so you could write it as string::size_type. std::string::size_type is the index type of std::string.Originally Posted by Masterx
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Last edited by Masterx; 01-23-2009 at 11:49 AM.
Highlight Your Codes
The Boost C++ Libraries (online Reference)
Bill Bryson"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
soorry to bother , thanks alot Dears. it went all fine , but i got some problem , i cant use "atoi() with string ! what should i do now ?atol() ? does it make it?
Code:for (string::size_type i = found, len = str.length(); i != len; ++i) { currentcharacter = str[i]; if ( (isspace(currentcharacter) )) { continue; } str1+= str[i];
You actually "solved" this problem in your original code by using the c_str() member function of std::string.Originally Posted by Masterx
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Highlight Your Codes
The Boost C++ Libraries (online Reference)
Bill Bryson"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
by the way , how could you guys understand that ptr was not allocated ! ? by experience or just its the knowledge of C++ that i can find in books/.?
Highlight Your Codes
The Boost C++ Libraries (online Reference)
Bill Bryson"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
Stringstreams.
Code:string s("12345"); int n; stringstream ss(s); ss >> n;
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
Highlight Your Codes
The Boost C++ Libraries (online Reference)
Bill Bryson"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
Highlight Your Codes
The Boost C++ Libraries (online Reference)
Bill Bryson"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."