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 support@ccsinfo.com

string comparison error

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



Joined: 12 Dec 2005
Posts: 50
Location: Curitiba - Brazil

View user's profile Send private message Send e-mail

string comparison error
PostPosted: Thu Dec 14, 2006 6:52 pm     Reply with quote

MPLAB 7.41 CCS 4.005 PIC18F2550
Hi all,
I am just trying to compare a string to a constant but I am receiving 2 compiler errors:
1) attempt to create a pointer to a constant
2) a numeric expression must appear here

The error is here:
Code:

#include <STDLIB>
#include <stdlibm.h>
#include <string.h>
//char bufrx[100];
char *bufrx;
bufrx = malloc(100);
if(strcmp(bufrx,"AT   ")==0)   // equals   <<<--- the error is in this line
{   memset(bufrx,0,pointer);
                pointer=0;
}


I declared bufrx both as a char matrix and a pointer with malloc allocation. Both return the same errors.
I also tried to create my own compare_strings_ function similar to strcmp but a similar error appeared when I declared the function.
What am I missing ?

Thanks in advance for any help
Pasini
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Dec 14, 2006 8:02 pm     Reply with quote

You must copy the constant string to a RAM buffer first.
See my post near the end of this thread for an example:
http://www.ccsinfo.com/forum/viewtopic.php?t=24212
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