isbn.cpp: In function 'int isValid(const char*)':
isbn.cpp:25: error: invalid conversion from 'const char' to 'const char*'
isbn.cpp:25: error: initializing argument 1 of 'int atoi(const char*)'
isbn.cpp:25: error: ISO C++ forbids comparison between pointer and integer
isbn.cpp:25: error: ISO C++ forbids comparison between pointer and integer
Code:
Function
int isValid(const char str[])
Code:
Line giving errors
/* determine if string contains non-numeric
characters (aside from check digit being an 'X') */
for (int i = 0; i < 10; i++)
/* fail check if atoi returns fail to convert (0),
character being checked is not 0 and last digit is
not an "X" */
if (atoi(str[i]) == 0 and str[i] != "0" and (i != 9 and str[i] != "X"))
validNumerals = false;
Now, these errors go away if I put const char* str[] rather than const char str[] but then strlen does not work.
Any advice?