I have the following code, for some reason when I try to use a
using namespace std;
cout<<"Content of Wholecommand: "<<wholecommand<<endl; //returns apple
cout<<"Length of Wholecommand: "<<wholecommand.length()<<endl; //returns 5
cout<<"Content of attributes: "<<atrribs<<endl; ////////contains nothing
cout<<"Length of attributes: "<<atrribs.length()<<endl; ////////returns 0
for() loop to get this working properly.
You cannot assign values via
std::string indices, where the target string wasn't resized to match them.
Though it's questionable, what's the purpose of your code sample as is at all? You can simply achieve the same with
atrribs = wholecommand;