Question: What I need to do is read a file which contains equations. I need to take the derivative of each equation and then write those derivative equations in a different .txt file. I've read all the equations into an array of character arrays and now I don't know what to do once I've stored them into the array. I really don't need help writing the equations into another file; I know I can figure that out.

What I need help on is finding a way to taking the derivative of the functions. The type of equations that are going to be read are not that complicated; they're going to be polynomials that don't need the chain rule or quotient rule. There will be, however, *sin x*, *cos x* and *tan x*. Some sample equations that would be read are.

```
-2x^2+2x-3

-2x+sinx-3

-x+sin2x-tanx

```

The trig functions will not have parenthesis and the variable will always be "x".
I just need a push in the right direction, please.

Answer: 
What you're really asking for is a [parser](https://stackoverflow.com/questions/5853136/how-do-i-write-a-parser-in-c-or-objective-c-from-without-a-parser-generators).
A parser is basically a set of rules to read those equations and change/read (parse) each of them.
I'd try to iterate over each line of the file, and differentiate it considering you have a specific character set (i.e ^ means power, x is the parameter, etc.);

For example, some pseudo code:

```
Open the file.
While there's lines to read:
   Read a line - 
   Seperate it by the operands (+,-,/,*)
   For each part:
     Find the power of x,
     Reduce it by one,
     ...(derivating rules) // no way around, you have to implement each function if you want this to work as others mentioned in the comments.
   Reconnect the parts into a string,
   Add it to a list.
 Print each element of the list.

```

If you need help translating that into C, just ask for it; I'll happily help you.
This function will parse the text, cut it in to different parts identified by `type[i]`, stores in a structure. It recognizes `x`, +, -, and numbers. It can be expand it to include other operators etc. 

```
#define maxlen 50

#define idx         0 //X variable
#define idnumber    1 //number
#define idplus      2 //+ sign
#define idminus     3 //- sign

struct foo
{
    int type[10];//each type can be a number (idnum), +, -, etc.
    int num[10];//if type[i] is number then num[i] identifies that number
    int count;//total number of parts
};

void parse_one_line(struct foo *v, const char *s)
{
    char buf[maxlen];
    memset(buf, 0, maxlen);
    int j = 0;
    //remove white spaces
    for (int i = 0, len = strlen(s); i < len; i++)
    {
        if (s[i] == ' ') continue;
        buf[j] = s[i];
        j++;
    }

    char part[maxlen];
    v->count = 0;
    for (int i = 0, len = strlen(buf); i < len; i++)
    {
        char c = buf[i];
        if (c == 'x')
        {
            v->type[v->count] = idx;
            v->count++;
        }
        else if (c == '+')
        {
            v->type[v->count] = idplus;
            v->count++;
        }
        else if (c == '-')
        {
            v->type[v->count] = idminus;
            v->count++;
        }
        else if (c >= '0' && c <= '9')
        {
            int j = 0;
            memset(part, 0, maxlen);
            for (; i < len; i++)
            {
                c = buf[i];
                if (c >= '0' && c <= '9')
                {
                    part[j] = c;
                    j++;
                }
                else
                {
                    break;
                }
            }
            i--;
            v->num[v->count] = atoi(part);
            v->type[v->count] = idnumber;
            v->count++;
        }
    }
    for (int i = 0; i < v->count; i++)
    {
        switch (v->type[i])
        {
        case idnumber: printf("%d", v->num[i]); break;
        case idx: printf("X"); break;
        case idplus: printf("+"); break;
        case idminus: printf("-"); break;
        default:break;
        }
    }
    printf("\n");
}

int main()
{
    struct foo st;
    parse_one_line(&st, "-23x + 2 + 2x - 3");
    return 0;
}

```