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)
1 Odpowiedź
0
int yourAtoi(char[] someString){
//do sth here
return sth;
}
int main(){
char num[]="1234";
cout<<yourAtoi(num);
}
👍