string s; cin>>s; suppose s = "stackoverflow"
now if we access s[3], it should give out 'c'
will s[3] be 'c' or "c"?
as in will it be a char data type or string data type?
string s; cin>>s; suppose s = "stackoverflow"
now if we access s[3], it should give out 'c'
will s[3] be 'c' or "c"?
as in will it be a char data type or string data type?
std::string is not a built-in type, so operator [] in s[3] is a call to a member function defining this operator in the string template.
You can find the type by looking up the reference page for operator []:
Returns a reference to the character at specified location pos.
To look up the type reference and const_reference from the documentation see "member types" section of std::basic_string<CharT> template.
If you are looking for std::string of length 1 starting at location 3, use substr instead:
s.substr(3, 1); // This produces std::string containing "c" reference" in the parent page and untangle the template usage to finally get "char&".