Suppose I have a string \"qwerty\" and I wish to find the index position of the e character in it. (In this case the index would be 2)
\"qwerty\"
e
2
What about:
char *string = "qwerty"; char *e = string; int idx = 0; while (*e++ != 'e') idx++;
copying to e to preserve the original string, I suppose if you don't care you could just operate over *string