(1)
c_str() converts a C++ string into a C-style string which is essentially a null terminated array of bytes.
you can see in documentation the syntax of strtok is
char * strtok ( char * str, const char * delimiters );
as you can see it accept char string (str) and also return char*
but we have string as argument
so for that we convert string to char* using c_str (as internally string is character array so we can say we are accessing underlying character array)
(2)
pair datatype is a pre define class in which u can group two datatypes together
say
pair<int ,float>
pair<int,string>
pair<string,string>
etc.
To reference them say we created pair<int,string> p=make_pair(5,“Hi”);
then cout<<p.first<<" "<<p.second; this will print 5 Hi
(3)
this is simple function
suppose s = “1234”
then we are each character of string from end
first we have s[3] which is ‘4’ (a character)
to convert character 4 to int we have subtracted it with ‘0’
s[3]-‘0’ will give us integer 4
str[i] is a character and will give corresponding ascci value as int
and we subtract ‘0’ from it to make it int
i.e ‘0’-‘0’ gives 0
‘1’-‘0’ gives 1
and so on
and similary we have done with other
and join them according to their place values so fron string " 1234" it gives int 1234