This is kind of awkward because I took this example from another site, but I like this forum more. (I use both sites for reference though). Anyways- I have a question about this code:
printf ("Splitting string \"%s\" into tokens:\n",str); \\ this is what confuses me. What the is \"%s\" used for? Another question that I have is why is his sample string a char?
/* strtok example */
int main ()
char str ="- This, a sample string.";
char * pch;
printf ("Splitting string \"%s\" into tokens:\n",str);
pch = strtok (str," ,.-");
while (pch != NULL)
pch = strtok (NULL, " ,.-");
I'm a noob but I'm trying to complete a project that I designed for myself. I'm having a hard time splitting strings into tokens or arrays and finding bits of information. My finished product would hopefully do this:
1) ask a question (an essay question that has multiple answers)
2) receive input
3) search input for possible answers
4) let the user know whether he/she is correct
I need help with #3; what are my options for functions/methods?