this code
Code:
#include <stdio.h>
#include <string.h>
int main(){
char *str1 = "A";
char *str2 = "A";
char *str3 = "!";
printf("\n str1 = %s", str1);
printf("\n str2 = %s", str2);
printf("\n str3 = %s", str3);
printf("\nstrcmp(str1, str2) = %d", strcmp(str1, str2));
printf("\nstrcmp(str1, str3) = %d", strcmp(str1, str3));
printf("\nstrcmp(str3, str1) = %d", strcmp(str3, str1));
if (strcmp(str1,str2) == 0) {
printf("\n%s is equal to %s", str1, str2);
}//if
if (strcmp(str1, str3) > 0) {
printf("\n%s is greater than %s", str1, str3);
}//if
if (strcmp(str3, str1 < 0)) {
printf("%s is less than %s", str3, str1);
}//if
return 0;
}//main
gives this output:
Code:
str1 = A
str2 = A
str3 = !
strcmp(str1, str2) = 0
strcmp(str1, str3) = 32
strcmp(str3, str1) = -32
A is equal to A
Program received signal: “EXC_BAD_ACCESS”.
sharedlibrary apply-load-rules all
the second "if" statement is not reached and I am unsure why?