What is the output of the following? - ProProfs Discuss
Advertisement

What is the output of the following?

echo strncasecmp(hello world, HelloWorld, 5), , ;
echo strcmp(44, 054), , ;
echo strcasecmp(xyz, ABC), , ;
echo strncmp(0, Z, 1), , ;
echo strcmp(bb, aaaa);

Asked by Aquiline, Last updated: Mar 30, 2024

+ Answer
Request
Question menu
Vote up Vote down

1 Answer

John Smith

John Smith

John Smith
John Smith

Answered Sep 08, 2016

0, 0, -23, -1, 1-e) is correct because for the first one, strncasecmp compares str1 to str2 in a case-insensitive fashion, for the first 5 charactersfor the second one, 054 (octal 44) is converted to decimal first, and then 44 == 44for the third one, strcasecmp, xyz is converted to uppercase or abc is converted to lowercase, and a is 23 positions away from x in asciifor the fourth one, 0 is compared to z, for the first 1 characters, letters (even uppercase ones) take precedence over numbersfinally, for the fourth one. even though bb is shorter than aaaa, b is higher than a, so str1 is greater
upvote downvote
Reply 

Advertisement
Advertisement
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader

Email Sent
We have sent an email to your address "" with instructions to reset your password.