Top

Discussion

What will be the output of the following C code?

const char str1[]="ABCDEF1234567";
const char str2[] = "269";
len = strcspn(str1, str2);
printf("First matching character is at %d\n", len + 1);

 

  • A.First matching character is at 8
  • B.First matching character is at 7
  • C.First matching character is at 9
  • D.First matching character is at 12

Answer: A

size_t strcspn(const char *str1, const char *str2) is used to calculate the length of the initial segment of str1, which consists entirely of characters not in str2.

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

Post your comment