I am trying to convert a char to an int that’s passed to a method:
volume('10');
void volume(char* number) {
for (int i = 0; i < atoi(number); i++) {
// do something 10 times
}
}
This doesn’t seem to be working.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Change:
to:
NB: if you had compiled with warnings enabled (e.g.
gcc -Wall ...) then the above errors would have been immediately apparent. Try to get into the habit of doing this and do not ignore warnings – they are there for a good reason and will often save you a lot of time debugging problems at run-time that could have been fixed at compile-time.