That is very easy. It is C which is 0
Each of these syntaxes apply to both strcmp and strcmpi. The strcmp function is case sensitive in matching strings, while strcmpi is not:
Description
Although the following descriptions show only strcmp, they apply to strcmpi as well. The two functions are the same except that strcmpi compares strings without sensitivity to letter case:
TF = strcmp('str1', 'str2') compares the strings str1 and str2 and returns logical 1 (true) if they are identical, and returns logical 0 (false) otherwise.
TF = strcmp('str', C) compares string str to the each element of cell array C, where str is a character vector (or a 1-by-1 cell array) and C is a cell array of strings. The function returns TF, a logical array that is the same size as C and contains logical 1 (true) for those elements of C that are a match, and logical 0 (false) for those elements that are not. The order of the first two input arguments is not important.
TF = strcmp(C1, C2) compares each element of C1 to the same element in C2, where C1 and C2 are equal-size cell arrays of strings. Input C1 and/or C2 can also be a character array with the right number of rows. The function returns TF, a logical array that is the same size as C1 and C2, and contains logical 1 (true) for those elements of C1 and C2 that are a match, and logical 0 (false) for those elements that are not.
These functions are intended for comparison of character data. When used to compare numeric data, they return logical 0.
Any leading and trailing blanks in either of the strings are explicitly included in the comparison.
The value returned by strcmp and strcmpi is not the same as the C language convention.
strcmp and strcmpi support international character sets
Examples
Perform a simple comparison of two strings:
strcmp('Yes', 'No')
ans =
0
strcmp('Yes', 'Yes')
ans =
1Create 3 cell arrays of strings:
A = {'MATLAB','SIMULINK'; ...
'Toolboxes', 'The MathWorks'};
B = {'Handle Graphics', 'Real Time Workshop'; ...
'Toolboxes', 'The MathWorks'};
C = {'handle graphics', 'Signal Processing'; ...
' Toolboxes', 'The MATHWORKS'};Perform a comparison of two cell arrays of strings. Compare cell arrays A and B with sensitivity to case:
strcmp(A, B)
ans =
0 0
1 1Compare cell arrays B and C without sensitivity to case. Note that 'Toolboxes' doesn't match because of the leading space characters in C{2,1} that do not appear in B{2,1}:
strcmpi(B, C)
ans =
1 0
0 1
Take care.
2007-04-03 14:07:22
·
answer #1
·
answered by Ms. Dell XPS 5
·
2⤊
0⤋
I believe the answer should be D. "Silver" is greater than "Gold" so it will return a positive number, 1. If they are equal it will return 0, and if the first is less than the second it will return -1. I could have those mixed up though, but that is the way it works in PHP (the person above me is wrong). Do a google search to make sure.
I actually think it returns the distance between the characters in most languages, but from your options, that is incorrect.
2007-04-03 14:10:15
·
answer #2
·
answered by Nisovin 5
·
0⤊
0⤋
The anser is C. Strcmp returns 0 is str1 is less then or greater than str2. Returns 1 if they are equal. In PHP that's how that works.
2007-04-03 14:03:55
·
answer #3
·
answered by Anonymous
·
1⤊
1⤋
gcc (GCC) 3.4.6
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
bash-3.1$ cat k.c
#include
int main(void){
printf("%d\n", strcmp("Silver","Gold"));
}
bash-3.1$ gcc k.c;a.out
1
The answer is D. My reason should be apparent.
2007-04-03 16:45:19
·
answer #4
·
answered by Vegan 7
·
0⤊
0⤋
e
2007-04-03 13:57:10
·
answer #5
·
answered by Vanderbere 2
·
0⤊
0⤋
the correct answer is MY answer - cause I'm always right
:P~~~~~
lol
2007-04-03 13:59:30
·
answer #6
·
answered by dreddful1 5
·
0⤊
1⤋
WHO THE **** CARES!?
2007-04-03 13:58:28
·
answer #7
·
answered by Katie 2
·
1⤊
2⤋