#include <iostream>
#include <cstdlib>
#include <cstring>
int main() {
char log[] =
"CMD:MOVE,X=10,Y=20;"
"CMD:STOP;"
"CMD:MOVE,X=50,Y=80";
int MoveCount = 0;
char * ptrline = strtok(log, ";");
while(ptrline != NULL)
{
char * xPtr = strstr(ptrline,"CMD:") ;
if(xPtr != NULL)
{
if(strncmp(xPtr+4,"MOVE",4) == 0)
{
MoveCount++;
}
}
ptrline = strtok(NULL,";");
}
printf("MOVE Count = %d", MoveCount);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: