0

I'm trying to build a manually "atoi" function without the <string> library

so far here is were I got which works only for one digit #include<iostream> using namespace std; int myAtoi(int someChar) { int num = someChar - 48; return num; } int main() { char aChar; cin >> aChar; cout << myAtoi(aChar); return 0; } any ideas for a char[]? (avoiding the string)

5th Feb 2019, 3:09 AM
Josh
Josh - avatar
1 Odpowiedź
0
int yourAtoi(char[] someString){ //do sth here return sth; } int main(){ char num[]="1234"; cout<<yourAtoi(num); } 👍
5th Feb 2019, 6:57 AM
LetterC67
LetterC67 - avatar