0

So I'm trying to build this simple (incomplete) C program in Visual Studio Express 2013 and I get the linker error "unresolved external symbol _strtok referenced in _split".

This confuses me since I was pretty sure my string.h include would include a strtok definition?

#define _CRT_SECURE_NO_WARNINGS

#include <string.h>
#include "parser.h"


char split (char *str[]) {
    char delimiter[] = " ";
    char *result;
    char strArray[10];
    int count = 0;

    result = srtok(str, delimiter);

    while (result) {
        strcpy(strArray[count++], result);
        //result = strtok(0, delimiter);
    }

    return strArray;
}

void *parse (char *cmdline) {
    char *commands = split(*cmdline);
    printf("%s\n", commands[0]);
}

Any ideas? Thanks.

Pancakes
  • 149
  • 2
  • 7
  • 3
    You've spelt the function `srtok` in your example (although that should result in a compiler error rather than a linker error) – Praetorian Apr 23 '14 at 04:22
  • I retyped that line a few times when I was messing around, must have typed it wrong but I swear it was strtok the first time I got the error. I've changed it to strtok and now it compiles without the error! Maybe it was just a typo but I was pretty sure I checked that... Sorry for wasting your time. – Pancakes Apr 23 '14 at 05:05

0 Answers0