Is there a C library function that will return the index of a character in a string?
So far, all I\'ve found are functions like strstr that will return the found cha
You can use strstr to accomplish what you want. Example:
char *a = "Hello World!"; char *b = strstr(a, "World"); int position = b - a; printf("the offset is %i\n", position);
This produces the result:
the offset is 6