Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maybe use sscanf? #42

Open
AndrewChe7 opened this issue Sep 19, 2020 · 1 comment
Open

Maybe use sscanf? #42

AndrewChe7 opened this issue Sep 19, 2020 · 1 comment

Comments

@AndrewChe7
Copy link

static int my_atoi(const char *c) {

for atoi function really hard to check errors, because it returns integer for input params, so you can't check it for bad input. You can use sscanf(buf, "%d", &n) to get integer from string and return value will be != 1 if there is problems.

@syoyo
Copy link
Owner

syoyo commented Sep 20, 2020

I want libc free and libc's atoi() and sscanf is affected by locale(e.g. see https://forum.openframeworks.cc/t/problem-with-locale-and-sscanf-ofximgui-related/30178 ), so provided our own implementation.

You can send a better atoi implementation(e.g. implement more robust one add more error checks). PR is always welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants