In the str char array below I would first like to locate the first math symbol I see, then I would like to count backwards and remove whatever is between the previous three " _ " and remove the three " _ ". Can I please get some ideas on how to do this?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int main(int argc, char *argv[])
{
char str [] = "xa_55_y_*_z_/_+_x_+";
int length = 0;
int decrementor = 0;
int underscore_counter = 0;
int i = 0;
length = strlen (str);
for(i = 0; i < length; i++)
{
decrementor = 0;
underscore_counter = 0;
if(str[i] == '*' || str[i] == '/' || str[i] == '+' || str[i] == '-')
{
decrementor = i;
while(underscore_counter != 3)
{
if(str[i] == '_')
{
underscore_counter++;
}
decrementor--;
}
}
}
return 0;
}