I have a buffer which contains bunch of data. I want to take out the index at some desired string stored on which line number in that buffer. for ex
buffer A = {'0','1',0x0D,0x0A,0, '2','3',0x0D,0x0A,0, '4','5',0x0D,0x0A,0, '6','7',0x0D,0x0A,0}
I want to point the line location at which string "45\r\n" stored in this buffer
so the answer is 2.
here is my code.
but every time I am getting answer 0. Please help
int16 stringIndex(uint8 * S,uint8 * T) { uint16 i,l;
l=strlen(T);
for(i=0; * (S+i); i++) { if(strncmp(S+i,T,l)) return i; }
return -1; }
void main(void {
uint8 A[25];
sprintf( A,"01\r\n%c23\r\n%c45\r\n%c67\r\n%c,0,0,0,0");
stringIndexValue = stringIndex(A,"45\r\n"); }