implicit declaration of function ‘strtok_r’ [-Wimplicit-function-declaration] inspite including <string.h>

strtok_r is not a standard C function. You have asked for only C99 by using the -std=c99compiler flag, so the header files (of glibc) will only make the standard C99 functions in string.h available to you.

Enable extensions by using -std=gnu99 , or by defining one of the extensions, shown in the manpage of strtok , that supports strtok_r before including string.h. E.g.

#define _GNU_SOURCE
#include <string.h>

Note that the code have other problems too, strtok_r returns a char * , but you are trying to assign that to a char array in integer = strtok_r(str2, delimiter2, &saveptr2);. Your integer variable should be a char *


Same problem with GCC 7.4.2 on Debian

Solved using __strtok_r or -std=gnu99 or adding a protoype after includes:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define BUFFER_SIZE 1024

extern char *strtok_r(char *, const char *, char **);