Is there a function in c that will return the index of a char in a char array?

后端 未结 6 1676
难免孤独
难免孤独 2021-01-01 14:20

Is there a function in c that will return the index of a char in a char array?

For example something like:

char values[] = \"0123456789ABCDEFGHIJKLMN         


        
6条回答
  •  抹茶落季
    2021-01-01 14:45

    You can use strchr to get a pointer to the first occurrence and the subtract that (if not null) from the original char* to get the position.

提交回复
热议问题