Fseek doesn't do what it should do in C
<p>I made a program to read .csv files. Every new line is after '\n' and every next element is after ','. The whole code is working fine for me. I get place (col and line) and I am trying to change the value in this place by reading the whole file into an array and then search the place with 'i' and trying to fseek that start from 'i' to change there only the needed value, but when I debug I found out that <code>arr[i]</code> (the chosen value), is not in the same place as <code>fseek(csvfile, i, SEEK_SET)</code>.</p>

<p>Can someone tell me how I <code>fseek</code> the file pointer to the 'i' place to change the value?</p>

<pre><code>int changeValue(int line, int col, char str[], const char* path)
{
    FILE* csvFile = fopen(path, "r+");
    char arr[VERY_BIG_MEMORY];
    int i = 0;
    int ch = 0;
    int q =0;
    if (!csvFile)
    {
        printf("Can't read the file\nPlease open a file\n");
        return -1;
    }
    initarr(arr, VERY_BIG_MEMORY);
    do
    {
        ch = fgetc(csvFile);
        arr[i] = (char)ch;
        i++;

    } while (ch != EOF);
    fseek(csvFile,0L, SEEK_SET);
    i = 0;
    q = 1;
    while (q &lt; line)
    {
        ch = arr[i];
        if (ch == '\n')
        {
            q++;
        }
        i++;

    }
    q = 1;
    while (q &lt; col)
    {
        ch = arr[i];
        if (ch == ',')
        {
            q++;
        }
        i++;

    }
    q = 0;
    fseek(csvFile,i,SEEK_SET );
    //ch = arr[i];
    //ch = fgetc(csvFile);
    /*while (str[q])
    {
        fputc(str[q], csvFile);
        q++;
    }*/
    fclose(csvFile);
}
</code></pre>