I am running a C program that has some string split function calls.
Undefined symbol "strtok@FBSD_1.0" - During the string split, i get this call, i can clearly tell its the strtok function which is a tokenizer function. I have it in these files
It should be defined in string.h which i have included in the str.h header file shown above. What could be causing this?
Undefined symbol "strtok@FBSD_1.0" - During the string split, i get this call, i can clearly tell its the strtok function which is a tokenizer function. I have it in these files
Code:
#pragma once
#include <stdint.h> /* uint */
#include <string.h> /* char */
#include <stdarg.h> /* unknown number of arguments */
#include <stdio.h
/* user includes */
#include "characterArr.h"
/* user includes */
/* find a string in-between 2 other strings */
char* findBetween(char* left, char* right, char* fullString);
/* combine 2 strings into a new string */
char* combineString(int num, ...);
/* used to split the text file string so that only the token is stored */
void splitString(struct Arr* arr, char* str, char *delim);
/* replace all occurences of string with another */
void replaceString(char* original, char toReplace, char newChar);
Code:
/* user includes */
#include "str.h"
/* user includes */
void splitString(struct Arr* arr, char* str, char* delim) {
if (!initialAlloc(arr)) {
exit(1);
}
char* subStr = strtok(str, delim);
while (subStr != NULL) {
addToArr(arr, subStr);
subStr = strtok(NULL, delim);
}
}
char* findBetween(char* left, char* right, char* fullString) {
int indexL = strstr(fullString, left) - fullString;
int indexR = strstr(fullString, right) - fullString;
char* parsed = calloc((indexR - indexL - strlen(left)), sizeof(char));
strncpy(parsed, fullString + indexL + strlen(left), indexR - indexL - strlen(left));
return parsed;
}
char* combineString(int num, ...) {
char* finalStr;
finalStr = calloc(600, sizeof(char));
va_list vaList;
/* initialize */
va_start(vaList, num);
for (int x = 0; x < num; x++) {
char* str = va_arg(vaList, char*);
strcat(finalStr, str);
}
va_end(vaList);
return finalStr;
}
void replaceString(char* original, char toReplace, char newChar) {
for (int i = 0; i < strlen(original); ++i) {
if (original[i] == toReplace) {
original[i] = newChar;
}
}
}