Reputation: 81
I used strsep() in C code, but I got this error.
void get_token()
{
char *token;
char *stringp;
int n = 1;
stringp = buf;
while( stringp != NULL )
{
token = strsep(&stringp, "\t\n");
switch(n) {
case 1 : strcpy(label, token);
case 2 : strcpy(opcode, token);
case 3 : strcpy(operand, token);
} n++;
}
}
This is my code and I using strsep() like this. I don't know the error said int. strsep() return char* I think.
Upvotes: 0
Views: 1094
Reputation: 36607
You are using an implementation that does not declare strsep()
in <string.h>
.
Consequences are;
strsep()
returns int
(hence the first warning)ld
) does not find a function named strsep()
in libraries included in the link (hence error about strsep()
being unresolved by ld
).The reason this occurs is that strsep()
is not part of the standard C library. You either need to obtain a library that contains it, or "roll your own" version of strsep()
.
Upvotes: 3