1.

Which among the given options compares atmost n characters of string ch to string s?(a) int strncmp(ch, s, n)(b) int strcmp(ch, s)(c) int strncmp(s, ch, n)(d) int strcmp(s, ch)The question was posed to me in unit test.This interesting question is from String Operations topic in section String Operations in C of C

Answer»

Correct choice is (a) int strncmp(CH, s, n)

Explanation: int strncmp(ch, s, n)is USED to COMPARE at most n CHARACTERS of string ch to string s; return <0 if ch0 of ch >s.



Discussion

No Comment Found

Related InterviewSolutions