How to use strtok_s in C

1 Answer

0 votes
#include <stdio.h>
#include <string.h>

int main(void)
{
    char string[] = "c c++\tjava, python\nphp javascript \n c#";
    char delimiters[] = " ,\t\n";
    char* token = NULL;
    char* next_token = NULL;

    token = strtok_s(string, delimiters, &next_token);

    while ((token != NULL)) {
        if (token != NULL) {
            printf("%s\n", token);
            token = strtok_s(NULL, delimiters, &next_token);
        }
    }

    char ch = getchar();

    return 0;
}
 



/*
run:

c
c++
java
python
php
javascript
c#

*/

 



answered Apr 8, 2022 by avibootz
edited Apr 8, 2022 by avibootz

No related questions found

...