why we can’t we do this?
Converting string to int
@tishya_goyal typecasting like that is allowed only for elementary data structures like int, char, etc. Strings are basically just character arrays, and conversion like this is not possible for an array. Although, you can take advantage of the inbuilt functions
-
int stoi(string s)
Converts string to integer -
string to_string(int n)
converts integer to string
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.