Code: Select all
SubString = "100150C4304E2512" ;
res = strchr(SubString, 'C');
res = 67
#1 Post by HyperUniverse » 06 Oct 2022 21:07
Code: Select all
SubString = "100150C4304E2512" ;
res = strchr(SubString, 'C');
res = 67
#2 Post by hexreader » 07 Oct 2022 10:31
Code: Select all
SubString = "100150C4304E2512" ;
Code: Select all
// random code for forum Author will deny all responsibility for this terrible code
// do not do this!!! this is a BASIC mind set, and silly for C
char SubString[] = "100150C4304E2512" ;
char *res; // pointer for memory address
void main() {
TRISB = 0; // all output for LEDs
LATB = 0; // initialise
res = strchr(SubString, 'C'); // get a memory pointer value into res
if(res){ // only process if non-zero (character found)
LATB = (res - &SubString) + 1; // get a BASIC style result - you do not want to do this
}
else{
LATB = 0; // character not found
}
while(1); // loop forever to aid debugging
}
Return to “mikroC PRO for PIC General”