I am referring to this post on how to create a string from a char in cpp.
Convert a single character to a string?
c is a charactor and inputstr is a vector of strings. As stated, if I do this
string str2(1,c);
inputstr.push_back(str2);
it works and inputstr gets a str append to the end but not when I do
inputstr.push_back(string str2(1,c));
It throws an error: expected primary-expression before ‘strx’ inputstr.push_back(string strx(1,c)); What does the error mean? is it because cpp does not support in line declaration, I would expect a different error in that case.
inputstr.push_back(string(1,c));.