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

strstr

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



Joined: 11 Jun 2005
Posts: 38

View user's profile Send private message

strstr
PostPosted: Sat Jan 06, 2007 7:41 am     Reply with quote

hallo i have a answer abaut strstr()
i need find this char 0x21,0xFF

i do this ;
....
char ck[]={0x21,0xFF}
char InMSG[40];

if(strstr(InMSG,ck) != NULL)
{

}

this find nothing!
why ?
i thinw that problem is 0xFF

thanks .
Ttelmah
Guest







PostPosted: Sat Jan 06, 2007 8:04 am     Reply with quote

The problem is not 0xFF, but zero!....
Your search term, is not a string. A 'string' in C, must be terminated with the '\0' character. By declaring ck the way you do (with two character constants), it does not have the required terminator, and so the search will actually be looking for extra garbage characters after your 21 FF values (which will depend on what else is in memory immediately after the ck declaration), so the search will not work.
Declare ck as:
char ck[]={0x21,0xFF,'\0'};

and the search should start working.

Best Wishes
ferrarilib



Joined: 11 Jun 2005
Posts: 38

View user's profile Send private message

PostPosted: Sat Jan 06, 2007 9:16 am     Reply with quote

thanks .
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