Top

Discussion

What will the following C code do?

char * strrchr(const char *s, int c )
char ch = c;
char *sc;
for(sc = NULL; ; ++s)
if(*s == ch)
SC = 9;
i f (*s =='\O' )
return (( char *) s);

 

  • A.find last occurrence of c in char s[ ].
  • B.find first occurrence of c in char s[ ].
  • C.find the current location of c in char s[ ].
  • D.There is error in the given code

Answer: A

The strrchr() function locates the last occurrence of c (converted to a char) in the string pointed to by s. String contains null character as a terminating part of it.

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

Post your comment