my code shows the problem this works
char str[] = "asdf=1=2=3"; // this works
printf("type: %s\n", typename(str)); // prints 'pointer to char'
char *token = strtok(str, "=");
printf("%s\n", token);
this works not , why ?
char *str2 = "asdf=1=2=3"; // this wont work
printf("type: %s\n", typename(str2)); // prints 'pointer to char'
printf("%s\n", str2);
char *token2 = strtok(str2, "="); // segmentation fault
printf("%s", token2);
edit: this is the typename macro
#define typename(x) _Generic((x), /* Get the name of a type */ \
\
_Bool: "_Bool", unsigned char: "unsigned char", \
char: "char", signed char: "signed char", \
short int: "short int", unsigned short int: "unsigned short int", \
int: "int", unsigned int: "unsigned int", \
long int: "long int", unsigned long int: "unsigned long int", \
long long int: "long long int", unsigned long long int: "unsigned long long int", \
float: "float", double: "double", \
long double: "long double", char *: "pointer to char", \
void *: "pointer to void", int *: "pointer to int", \
default: "other")