I have to make a program in which I have to add the result of x dices with n faces plus or minus a constant(C). The input should be a string like this: "xDn+-C" (x, n and C must be a decimal number). For example: "4D5+6" or "6D9-5". The D just means "Dice".

I used a function to randomize the rolls but I don't know how to continue...

```
void initD6(void) {

   srand((unsigned)time( NULL ) );
}

int D6(void) {

   return ((rand()%6)+1);
}

int main(){
   char Dice[4];

   for(i=0; i<5; i++){

   Dice[i] = D6();

   return 0;
}

```

I don't know how should I take that input as a string and the adding or substracting, and also don't know what should I do next.