Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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"
9th Feb 2022, 11:22 AM
Rupali Haldiya
Rupali Haldiya - avatar
+ 1
Use ASCII values
9th Feb 2022, 10:33 AM
Rupali Haldiya
Rupali Haldiya - avatar
+ 1
cout<<(int) 'A' ; Do you mean like this?
9th Feb 2022, 10:34 AM
Jayakrishna 🇮🇳
+ 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
9th Feb 2022, 11:16 AM
Jayakrishna 🇮🇳
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
11th Feb 2022, 1:01 PM
Bob_Li
Bob_Li - avatar
- 1
#include <string> String x ="7"; Int z = (int) x ; // = 7
10th Feb 2022, 12:37 PM
Yiu 2011