I have this piece of C++ code:
const char *Delim = "some text";
char *token;
...
token = strtok('\0', Delim); // error here
The error is as follows:
invalid conversion from 'char' to 'char*' [-fpermissive]
I tested this in GCC 5.3 and it worked. But in GCC 8.1 it fails and gives me the error.
I understand I hard-code the char value. However, the Delim variable is also hard-coded. What would be the right replacement for it to work regardless of GCC versions? And why?
Note: I tested the following to get it to compile, but I want to understand it a bit more
const char *Delim = "some text";
char *str_0 = "\0"; // still receive warning that ISO C++ forbids converting a string constant to 'char*'
car *token;
...
token = strtok(str_0, Delim);
Interestingly, the single quote did not work either:
const char *Delim = "some text";
char *str_0 = '\0'; // fails
car *token;
...
token = strtok(str_0, Delim);