fputc / fprintf fails to write to my file
<p>I am supposed to write a program that takes a text file (that contains plain text) and corrects the following mistakes (involving the punctuation):</p>

<pre><code>Hello , there! --&gt; Hello, there!
Hello ,there! --&gt; Hello, there!
A sentence. this should be capitalized --&gt; A sentence. This should be capitalized
</code></pre>

<p>The algorithm i've come up with is the following:
I loop through the text file line by line, and pass each line to a mistake finder function. This function detects the above (1st and 2nd) mistakes and stores a double number in the mistakes array. The integer part shows the position where the mistake begins and the decimal part shows the type of mistake found.</p>

<p>For example if i passed <code>"Hello , there!"</code> as an argument, the double that would be stored in the array is 5.1 since the mistake begins in the 5th character of the string and 0.1 because it's the 1st type of mistake.</p>

<p>Similarly <code>"Hello ,there!"</code> would store 5.2 in the array (2nd type of mistake).
After locating the mistakes, a piece of code writes the new corrected line in a different file.</p>

<pre><code>FILE *src, *dst; //source file, destination file
int ptr; //shows how many mistakes were found in the line 
src = fopen((const char*)filename, "r"); //opening both files
dst = fopen("temp.txt", "w");
char array[1024];
double mistakes[1024];
double mistakeType, position;
int i, j, pos = 0, capitalNeeded = 1; //capitalNeeded shows whether the next letter should be capitalized


while(fgets(array, 1024, src)!=NULL){ //taking the content of the file line by line
    puts(array);
    ptr = findMistakes(array, mistakes); //the mistakes of the current line are located, and their types are defined

    for(i=0; i&lt;ptr; i++){ //looping through the mistakes
        if(capitalNeeded &amp;&amp; isalpha(array[pos])){
            array[pos] = toupper(array[pos]);
            capitalNeeded = 0;
        }
        mistakeType = modf(mistakes[i], &amp;position); //position will be of type int.0000..
        for(j=pos; j&lt;position; j++){
            if(array[j] == '.' || array[j] == '?' ||array[j] == '!'){ //testing if a capital letter is needed
                capitalNeeded = 1;
            }
            if(capitalNeeded &amp;&amp; isalpha(array[j])){
                array[j] = toupper(array[j]);
                capitalNeeded = 0;
            }
        }
        pos = j+1; //pos becomes the last j+1, basically shows the next character to be read from the array

        if(mistakeType == 0.1){ //if mistake was of type 1
            //then pos points to a space character ' '. The space is bypassed and the next 
            //character is placed in the file
            fprintf(dst, "%c", array[pos+1]); //which is a punctuation character
            fprintf(dst, "%c", array[pos+2]); //then a space is placed
            pos += 3; //the next character to be read and placed becomes pos+3
        }
        else{ //only 2 type of mistakes exist, so if it's not of type 1 then it's of type 2
            //In a type 2 mistake the punctuation mark is attached to the next letter
            //pos currently points to a space character ' ', and pos+1 to a punctuation mark.
            fprintf(dst, "%c", array[pos+1]);
            fprintf(dst, "%c", array[pos]);
            pos += 2; //the next character to be read and placed becomes pos+2
        }
    }
    fprintf(dst, "%c", '\n'); //the line is changed
    pos = 0; //pos is reset, and readied for the processing of the next line


}
</code></pre>

<p>However, i haven't been able to tell if my algorithm works because <code>fputc</code> won't work. There's no error in the compilation, but the new file is empty. I understand that <code>fputc()</code> takes <code>int</code> arguments, so i tried using <code>fprintf(dst, "%c", array[...]);</code>but that yielded the exact same results. I searched but couldn't find the answer, any help is appreciated...</p>