int compare_chars(const void* a, const void* b)
{
    char* c1 = (char*)a;
    char* c2 = (char*)b;
    return *c1 - *c2;
}
int main(int argc, char* argv)
{
    FILE* file = fopen("c:\\file.txt", "r");
    assert(file != NULL);
    char word[10] = { 0 };
    while (!feof(file))
    {
        fscanf(file, "%s", &word);
        qsort(word, 10, sizeof(char), &compare_chars);
        for (int i = 0; i < 10; i++)
            printf("%c", word[i]);
        printf("\n");
    }
    fclose(file);
}
I get the following message:
Run-Time Check Failure #2 - Stack around the variable 'word' was corrupted.
It happens on a valid file containing only "0123456789" (10 characters).
Why?
 
     
     
     
    