What is the output of the following? echo strncasecmp(hello world, - ProProfs Discuss
Topics
Products
Follow Us:

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);



A. 1, 1, 1, -1, 1
B. 0, 0, -1, -1, 1
C. 1, 1, -23, 1, -1
D. -1, 0, -1, 1, -1
E. 0, 0, -23, -1, 1

This question is part of php strings

Asked by Aquiline, Last updated: Jul 04, 2020

+ Answer
Request

1 Answer

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
 

Search for Google images
Select a recommended image
Upload from your computer
Search for Google images
Select a recommended image
Upload from your computer
Search for Google images
Select a recommended image
Upload from your computer

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