Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which standard library function will you use to find the last occurrence of a character in a string in C?

  • A.strnchar()
  • B.strchar()
  • C.strrchar()
  • D.strrchr()

Answer: D

Correct answer: strrchr()

strrchr() - the extra r is for reverse - returns a pointer to the last occurrence of a character in a string, or NULL if it is absent. It is the usual way to find a file extension or the last separator in a path. The other three names do not exist; strchr() finds the first occurrence.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.