How would I write a function that reads an ascii char string and returns the int value that it represents. ignoring leading whitespace and stop conversion at the first non digit character. If it is not possible, the function should return 0 and indicate an error condition.
I cant use runtime library routines such as “scanf”.
Cheers,
Jo
function that reads an ascii char string and returns the int value
Started by joninty, Mar 10 2010 08:12 AM
3 replies to this topic
#1
Posted 10 March 2010 - 08:12 AM
|
|
|
#2
Posted 10 March 2010 - 08:50 AM
Well that depends on what you CAN use. So what can you use??
#3
Posted 10 March 2010 - 12:33 PM
Is this in C or C++? Do you have access to the atoi() function?
#4
Posted 11 March 2010 - 12:56 AM
Hint: In ASCII, the characters '0' to '9' are consecutive. So if you were to subtract...
sudo rm -rf /


Sign In
Create Account

Back to top









