View previous topic :: View next topic |
Author |
Message |
hadeelqasaimeh
Joined: 05 Jan 2006 Posts: 105
|
small question |
Posted: Sat Jan 07, 2006 5:13 pm |
|
|
im sorry that im new with this compiler
just a queistion:
strcspn ()its supooesd to count of initial char in s1 not in s2,what dose this mean????
i try to print the result on lcd, but i have nothing,its supooesd to give integer isnt it???
her is the code Code: |
#include <16f874.h>
#include "lcd_kbd1.c"
#include <string.h>
#fuses XT,NOWDT,NOLVP
#use delay(clock=4000000) //one instruction=1us
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7,ERRORS)
static char RX[20],h,ptr,string1[20], string2[20],S1[10];
static int1 jj;
static int8 i;
int rink;
int1 res;
void main() {
LCD_Init ( );
strcpy(string1,"abcdefg");
strcpy(string2,"cdefg");
res=strcspn (s1, s2);
LCD_PutCmd ( CLEAR_DISP );
LCD_SetPosition ( LINE_16_1);
printf(LCD_PutChar,"res=",res);
}
|
thank u |
|
|
JBM
Joined: 12 May 2004 Posts: 54 Location: edinburgh, Scotland
|
|
Posted: Sat Jan 07, 2006 9:14 pm |
|
|
One problem is that in your printf statement, you haven't told the compiler how to print out the contents of res. To treat res as an unsigned int8, use this:
Code: |
printf(LCD_PutChar,"res=%u",res);
|
I have a feeling string functions return a signed value, but the manual should tell you - mine isn't to hand. This should at least show something.
-JBM |
|
|
hadeelqasaimeh
Joined: 05 Jan 2006 Posts: 105
|
|
Posted: Sun Jan 08, 2006 3:58 am |
|
|
hi JBM
I did what u talled me,it gives me res=1 all the time and this also not right
i mean when i change the char the same result appear<res=1 all the time
what can i do now???
thanx |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jan 08, 2006 4:04 am |
|
|
Quote: | it gives me res=1 all the time.
what can i do now??? |
Look closely at your code. What values can res hold ?
Quote: | static int8 i;
int rink;
int1 res; |
|
|
|
hadeelqasaimeh
Joined: 05 Jan 2006 Posts: 105
|
|
Posted: Sun Jan 08, 2006 8:41 am |
|
|
oops,.....yes thats it!!!!
thank u |
|
|
|