Write a C program that opens a text file, counts the number of words, lines, and characters in the file, and then writes these statistics to another text file.

```c
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int main() {
    FILE *inputFile, *outputFile;
    char ch;
    int characters = 0, words = 1, lines = 1;

    inputFile = fopen("input.txt", "r");
    if (inputFile == NULL) {
        printf("Error: Unable to open input file.\n");
        exit(1);
    }

    outputFile = fopen("output.txt", "w");
    if (outputFile == NULL) {
        printf("Error: Unable to open output file.\n");
        fclose(inputFile);
        exit(2);
    }

    bool inWord = false;
    while ((ch = fgetc(inputFile)) != EOF) {
        characters++;

        if (ch == '\n') {
            lines++;
        }

        if (ch == ' ' || ch == '\t' || ch == '\n') {
            inWord = false;
        } else if (!inWord) {
            inWord = true;
            words++;
        }
    }

    fprintf(outputFile, "Characters: %d\nWords: %d\nLines: %d\n", characters, words, lines);

    fclose(inputFile);
    fclose(outputFile);

    return 0;
}
```

This C program reads a text file named `input.txt` and counts the number of characters, words, and lines. It then writes these statistics to another text file named `output.txt`. The program uses standard file I/O functions such as `fopen`, `fclose`, and `fgetc`.

To compile and run this program, save it to a file called `count_stats.c`, then use the following commands:

```
gcc count_stats.c -o count_stats
./count_stats
```

Make sure you have an `input.txt` file in the same directory as the compiled program. After running the program, you should see an `output.txt` file containing the statistics for the input file.