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
- outputting ascii table in C++
- What is the effect of extern “C” in C++?
- What exactly is the difference between “pass by reference” in C and in C++?
- What does “collect2: error: ld returned 1 exit status” mean?
- Floating point exception (core dumped)
- Correct format specifier for double in printf
- Compiler Error “void value not ignored as it ought to be” in C programming [duplicate]
- Scanf/Printf double variable C
- What is EOF in the C programming language?
- Reading from file using read() function
- What is the difference between ++i and i++?
- warning: assignment makes integer from pointer without a cast
- munmap_chunk(): invalid pointer
- printf() formatting for hexadecimal
- The importance of c enumeration (typedef enum) [duplicate]
- How do I properly compare strings in C?
- How to convert an int to string in C?
- Process finished with exit code 11 | Error during malloc [duplicate]
- How can I convert a character to a integer in Python, and viceversa?
- How does wait(NULL) exactly work?
- What does strcmp() exactly return in C?
- How to replicate vector in c?
- Illegal Escape Character “\”
- C compile error: “Variable-sized object may not be initialized”
- In C, how should I read a text file and print all strings
- Convert char* to string C++
- What does “Size in TCHARs” means?
- return makes integer from pointer without a cast [-Wint-conversion] return candidate
- Math constant PI value in C
- How to convert C++ Code to C
- malloc for struct and pointer in C
- How do you pass a function as a parameter in C?
- C free(): invalid pointer
- Anyone know how to solve the error of “collect2.exe: error: ld returned 1 exit status” when a program in C is running?
- How to iterate over a string in C?
- Where is the C auto keyword used?
- How can one print a size_t variable portably using the printf family?
- How to make sense of modulo in c
- Escape Character in SQL Server
- Mapping a numeric range onto another
- Why are hexadecimal numbers prefixed with 0x?
- Uninitialized value was created by a heap allocation
- Makefile:1: *** missing separator. Stop
- Comparing the values of char arrays in C++
- Convert char array to single int?
- Invalid type argument of unary ‘*’ (have ‘int’) Error in C
- Why do I get “cast from pointer to integer of different size” error?
- Excess elements of scalar initializer for pointer to array of ints
- How does one represent the empty char?
- How to get the ASCII value in JavaScript for the characters [duplicate]
- Can I define a function inside a C structure?
- How to display hexadecimal numbers in C?
- A Simple, 2d cross-platform graphics library for c or c++?
- Removing last character in C
- Difference between char *argv[] and char **argv for the second argument to main()
- How do you format an unsigned long long int using printf?
- error : storage class specified for parameter
- Dereference void pointer
- Use of flag in c?
- Difference between “while” loop and “do while” loop
- Swapping 2 Bytes of Integer
- GDB no such file or directory
- Level vs Edge Trigger Network Event Mechanisms
- How to convert integers to characters in C?
- variably modified array at file scope in C
- How to use random() in C [duplicate]