Following is the error when "\" is used as delemiter for the example given by dhiraj.
check.cpp:8:21: warning: missing terminating " character
check.cpp:8: error: missing terminating " character
check.cpp: In function ‘int main()’:
check.cpp:9: error: expected primary-expression before ‘char’
check.cpp:9: error: expected ‘,’ or ‘;’ before ‘char’
check.cpp:10: error: ‘result’ was not declared in this scope
- #include <iostream>
-
#include <string.h>
-
using namespace std;
-
-
int main()
-
{
-
char str[] = "now # is the time for all # good men to come to the # aid of their country";
-
char delims[] = "\"; //// error because of this
-
char *result = NULL;
-
result = strtok( str, delims );
-
while( result != NULL ) {
-
printf( "result is \"%s\"\n", result );
-
result = strtok( NULL, delims );
-
}
-
return 0;
-
}
-
~