Find The First Occurrence Of A Character In A String | C Programming Example

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Simply use strchr.
Let's say we called our string "text".
Let's say we have called the variable in which we'll store the function call result "x".
Then if the call has success (i.e. does NOT return a NULL pointer) do something like this:
int index = (int)(x - text)
Et voilà.

vaporuwu