c++ - at() function to a new variable -
i put each char of string new string variable. how can that?
#include <iostream> #include <string> using namespace std; int main () { string str = "hello"; string = str.at(0); string b = str.at(1); string c = str.at(2); string d = str.at(3); string e = str.at(4); return 0; }
you can treat strings containers, may use following code:
char = str[0]; char b = str[1];
and if you'd convert character string, use following code:
string a(1, str[0]); string b(1, str[1]);
Comments
Post a Comment