+ 3
Every character must have an ascii value. If we convert "ABCD" to integers it should be like 65666768 and if we convert "1234" to integer it should be like 49505153...
Manav Roy please tell us your expected output for "ABCD"
+ 1
Use ASCII values
+ 1
cout<<(int) 'A' ;
Do you mean like this?
+ 1
Manav Roy "1234" is now in string format. It's equaling int value is 1234. It can be done easily..
stoi("1234") returns 1234, if put any non-valid number as argument, it will give you error.
But what is "ABCD" equalent in number?
I think, You can use binary convertion.. like:
ABCD :
01000001 01000010 01000011 01000100
0
Like Rupali said, the most common method is to convert each letter to it's ascii value.
But you can get creative like Runtime Terror 's or Jayakrishnaš®š³ 's suggestions.
It depends on what you are going to do with the result.
https://code.sololearn.com/ci5Sqk0wC36T/?ref=app
- 1
#include <string>
String x ="7";
Int z = (int) x ; // = 7