This repository has been archived on 2024-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
CodeBlocksPortable/WATCOM/samples/clibexam/strtok_s.c

23 lines
506 B
C
Raw Normal View History

#define __STDC_WANT_LIB_EXT1__ 1
#include <stdio.h>
#include <string.h>
void main()
{
char *p;
char *buffer;
char *delims = { " .," };
size_t buflen;
char *ptr;
buffer = strdup( "Find words, all of them." );
printf( "%s\n", buffer );
buflen = strlen( buffer );
p = strtok_s( buffer, &buflen, delims, &ptr );
while( p != NULL ) {
printf( "word: %s\n", p );
p = strtok_s( NULL, &buflen, delims, &ptr );
}
printf( "%s\n", buffer );
}