pasini
Joined: 12 Dec 2005 Posts: 50 Location: Curitiba - Brazil
|
string comparison error |
Posted: Thu Dec 14, 2006 6:52 pm |
|
|
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 |
|