V
Victor Eijkhout
I've used this function before but I'm suddenly getting bus errors:
%% cat tok.c
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(int argc,char **argv)
{
char *c,*fs; const char *sep = ",";
fs = "5,1";
c = strtok(fs,sep);
printf("1st: <%s>\n",c);
return 0;
}
%% cc tok.c ; a.out
Bus error
According to gdb the problem occurs in strtok, and the program "works"
if the separator string does not contain characters that are in the test
string.
This problem happens on Mac OS X (Apple-modified gcc 4), gcc 3.something
on Linux, but not with IBM's compiler on a Power5.
Anyone any idea what is happening here?
Victor.
%% cat tok.c
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(int argc,char **argv)
{
char *c,*fs; const char *sep = ",";
fs = "5,1";
c = strtok(fs,sep);
printf("1st: <%s>\n",c);
return 0;
}
%% cc tok.c ; a.out
Bus error
According to gdb the problem occurs in strtok, and the program "works"
if the separator string does not contain characters that are in the test
string.
This problem happens on Mac OS X (Apple-modified gcc 4), gcc 3.something
on Linux, but not with IBM's compiler on a Power5.
Anyone any idea what is happening here?
Victor.