kmp84
Joined: 02 Feb 2010 Posts: 354
|
strcmp problem |
Posted: Mon Jun 08, 2015 3:05 am |
|
|
Hi,
Any idea why "strcmp()" in this example return "0 (False)"?
CCS C ver.4.140
Code: |
#include <18F46K22.h>
#fuses HSM,PLLEN,NOWDT,NOBROWNOUT,PUT,NOPROTECT,NOCPD,NOFCMEN,MCLR
#use delay(crystal=8MHz, clock=32MHz) // HS Mode with PLLx4 (4*8MHz=32MHz)
#use RS232(DEBUGGER,rcv=PIN_C0,xmit=PIN_C0,STREAM=STREAM_MONITOR)//Debug Monitor at 2400 Default speed
#include <string.h>
void main() {
int8 s1[]={"1234567890"};
int8 s2[]={"1234567890"};
fprintf(STREAM_MONITOR,"\n\r S1: %s",s1);
fprintf(STREAM_MONITOR,"\n\r S2: %s",s2);
int8 res=0;
res=strcmp(s1, s2);
if(res) fprintf(STREAM_MONITOR,"\n\r s1 = s2");
else fprintf(STREAM_MONITOR,"\n\r s1 # s2");
while( 1 ) {
}
} |
Thanks for attention! |
|