I need a function that will convert a c++ string to an int andi can\'t use any s
ID: 3614175 • Letter: I
Question
I need a function that will convert a c++ string to an int andi can't use any standard method (no atoi or std libfunctions). We are supposed to write it using asciiconversion. So an example is this "321" is going to be converted by this method: asciivalue(3) - asciivalue(0) +asciivalue(2) - asciivalue(0) +asciivalue(1) - asciivalue(0) I need a function that will convert a c++ string to an int andi can't use any standard method (no atoi or std libfunctions). We are supposed to write it using asciiconversion. So an example is this "321" is going to be converted by this method: asciivalue(3) - asciivalue(0) +asciivalue(2) - asciivalue(0) +asciivalue(1) - asciivalue(0)Explanation / Answer
#include #include using namespace std; int stringToInt(string s) { int num=0; char c, zero='0'; int a, b; for(int i=0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.