The documentation for strtok_r is quite clear.
The strtok_r() function is a reentrant version strtok(). The saveptr argument is a pointer to a char * variable that is used internally by strtok_r() in order to maintain context between successive calls that parse the same string.
On the first call to strtok_r(), str should point to the string to be parsed, and the value of saveptr is ignored. In subsequent calls, str should be NULL, and saveptr should be unchanged since the previous call.
So you’d have code like
char str[] = "Hello world"; char *saveptr; char *foo, *bar; foo = strtok_r(str, " ", &saveptr); bar = strtok_r(NULL, " ", &saveptr);
Related Posts:
- Char Comparison in C
- char array not assignable
- How does strtok() split the string into tokens in C?
- What is an unsigned char?
- Get a substring of a char* [duplicate]
- char *array and char array[]
- Get a substring of a char*
- Expression must be a modifiable L-value
- What is the difference between char s[] and char *s?
- Char Comparison in C
- Return char[]/string from a function [duplicate]
- How can I use modulo operator (%) in JavaScript?
- Return char[]/string from a function
- How to print a char array in C through printf?
- Excess elements in char array initializer error
- How to do scanf for single char in C
- C char* to int conversion
- Convert char array to a int number in C
- Returning an array using C
- char pointers: invalid conversion from ‘char*’ to ‘char’?
- How to copy a char array in C?
- C: using strtol endptr is never NULL, cannot check if value is integer only?
- How to empty a char array?
- Does C have a string type?
- How does the strtok function in C work? [duplicate]
- Why do we use NULL in strtok()?
- Allocating char array using malloc
- Implementation of strtok() function
- C char array initialization
- The difference between char * and char[] [duplicate]
- strtok segmentation fault
- C: warning: excess elements in array initializer; near initialization for ‘xxx’ ; expects ‘char *’, but has type ‘int’
- How do I check if a string contains a certain character?
- Convert Char to String in C
- How big can a 64 bit unsigned integer be?
- The difference between n++ and ++n at the end of a while loop? (ANSI C)
- What is a segmentation fault?
- How many spaces for tab character(\t)?
- Implementing Taylor Series for sine and cosine in C
- Working on code to calculate cosine with factorial sum
- How to use execvp()
- How to use execvp() to execute a command
- warning: implicit declaration of function
- warning: implicit declaration of function
- What is *(uint32_t*)?
- What does (~0L) mean?
- pthread_join() and pthread_exit()
- What is size_t in C?
- What is the difference between float and double?
- what is Segmentation fault (core dumped)? [duplicate]
- What causes a segmentation fault (core dump) to occur in C?
- uint8_t vs unsigned char
- outputting ascii table in C++
- How to use symbols of extended ASCII table in C?
- Two questions about basic C programs
- What is the difference between ++i and i++?
- Using boolean values in C
- std::string to char*
- What does “collect2: error: ld returned 1 exit status” mean?
- How to convert an int to string in C?
- typedef struct vs struct definitions [duplicate]
- How to print in C
- What is the effect of extern “C” in C++?
- How to convert a char to a String?
- Why should we typedef a struct so often in C?
- How to convert/parse from String to char in java?
- Why are #ifndef and #define used in C++ header files?
- Arrow operator (->) usage in C
- strdup() – what does it do in C?
- strdup() – what does it do in C?
- What is a string of hexadecimal digits?
- Why should we typedef a struct so often in C?
- What exactly is the difference between “pass by reference” in C and in C++?
- What is the difference between ++i and i++?
- Conversion from string to char – c++
- What can be the reasons of connection refused errors?
- What does “collect2: error: ld returned 1 exit status” mean?
- How to convert an int to string in C?
- typedef struct vs struct definitions [duplicate]
- What is newline character — ‘\n’
- When to use extern “C” in simple words? [duplicate]
- Floating point exception( core dump
- “Char cannot be dereferenced” error
- Why does ENOENT mean “No such file or directory”?
- What does the question mark character (‘?’) mean?
- Cannot figure out how to use getchar(); in C
- Floating point exception (core dumped)
- “Char cannot be dereferenced” error
- How can I convert a char to int in Java? [duplicate]
- Undefined reference to pthread_create in Linux
- what is the difference between uint16_t and unsigned short int incase of 64 bit processor?
- makefile:4: *** missing separator. Stop
- Stack smashing detected
- Why am I getting “void value not ignored as it ought to be”?
- Correct format specifier for double in printf
- Compiler Error “void value not ignored as it ought to be” in C programming [duplicate]
- Stack smashing detected
- How do I determine the size of my array in C?
- Why am I getting “void value not ignored as it ought to be”?
- Mutex example / tutorial? [closed]