Top

Discussion

What will be the output of the following C code?

const char str1[] = "abcdef";
const char str2[] = "fgha";
char *mat;
mat= strpbrk(str1, str2);
if(mat)
printf("First matching character: %c\n", *mat);
else
printf("Character not found");

 

  • A.g
  • B.a
  • C.h
  • D.f

Answer: D

The strpbrk() function is used to locate the first occurrence in the string str1 of any character from the string str2.

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

Post your comment