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

strtok(NULL, ...) causes an unwanted warning #348

Closed
AlvajoyAsante opened this issue Jan 8, 2022 · 0 comments
Closed

strtok(NULL, ...) causes an unwanted warning #348

AlvajoyAsante opened this issue Jan 8, 2022 · 0 comments
Assignees
Labels

Comments

@AlvajoyAsante
Copy link

When running the following code using char *strtok(char *str, const char *delim):

int main (void) {
   char str[12] = "Hello World";
   char *token;

   token = strtok(str, " ");
   token = strtok(NULL, " ");
   
   return(0);
}

It gives an unwanted error stating:

warning: null passed to a callee that requires a non-null argument [-Wnonnull] 
 token = strtok(NULL, " ");
                ~~~~     ^

The issue is that strtok should be able to run a second iteration with a NULL as it's char *str without giving me a warning.

@AlvajoyAsante AlvajoyAsante changed the title strtok causes an unwanted warning strtok(NULL, ...) causes an unwanted warning Jan 8, 2022
@adriweb adriweb added the bug label Jan 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants