I have three questions,
- What will happen we pass -1 as value for 3rd parameter in strncmp() ie. n number bytes of bytes to compare?
- Why the output differs in ARM and PPC? ie. if which one correct?
If I use memcmp instead of strncmp, I m getting "inside else" output in both ARM and PPC. How and why?
char str[10]; memset(str,'\0',sizeof(str)); printf("str:%s ,len:%d\n\r",str,strlen(str)); if(strncmp(str,"Maximum",(strlen(str)-1)) == 0) { printf("inside if\n\r"); } else { printf("inside else\n\r"); }
Output in ppc
str: ,len:0
inside else
Output in arm
str: ,len:0
inside if