lets say i have a i have a char array

char left_var[]       //-33x-4x+x

this char left_var array has the value of "-33x- 4x+ x" and result should be "-33-4+1" and store in another array called
in another word iam trying to get rid of x's and if there is only one x than iam puting value 1 inside.

char left_var_num[]   //-33-4+1

note
we dont know what is the value inside char left_var[] so,
it could be +3x-444x+x-1x and result is +3-444+1-1
it could be x+x and reslut is 1+1
all we know is that it has alls x's and - or + sign in it.

--error--
and there are no error inside for ex. ++x-3x or 3-3x or 0x-3x will be not inside char left_car[]

/*******************************/
/*********** x-2x-3x ***********/
/*********** 1-2-3  ************/
/*******************************/
void variables_to_num(char left_var[], char left_var_num[])
{
  int b = 0;
  int lv = 0;

  int flag = 0;

   for(b = SIZE - 1; b > -1; b--)
    {
      if(left_var[b] != '\0')
    {
      if(left_var[b] == 'x' && left_var[b+1] != '+' && left_var[b+1] != '-')
        {
          flag = 1;
          b++;
        }
      if(left_var[b] == 'x' && left_var[b+1] == '+' && left_var[b+1]== '-')
        {
          flag = 1;
        }
      if(flag == 0)
        {
          left_var_num[lv] = left_var[b];
          lv++;
        }
      else if(flag == 1)
        {
          left_var_num[lv] = left_var[b];
          lv++;
          if(left_var_num[b] == '+' || left_var[b] == '-')
        {**Bold Text Here**
          flag = 0;
        }
        }
    }
      else 
    {
    }
    }
} 

also for some reason the value of char left_var[] is being change at end of the function.

which is wired bc iam only changing the value of char left_var_num[] >:(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.