CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

small question

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
hadeelqasaimeh



Joined: 05 Jan 2006
Posts: 105

View user's profile Send private message

small question
PostPosted: Sat Jan 07, 2006 5:13 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Jan 07, 2006 9:14 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Jan 08, 2006 3:58 am     Reply with quote

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??? Confused Shocked


thanx
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jan 08, 2006 4:04 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Jan 08, 2006 8:41 am     Reply with quote

oops,.....yes thats it!!!!
thank u Laughing
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group