#include <stdio.h> #include <string.h> int main() { char str[] = "I love Study"; printf("%d\n",strchr(str,'o')-str); //输出结果为3 为'o'对应的下标 return 0; }