const char chars[] = "abcdef ....";
char result[...];
memcpy(result, chars, sizeof(chars));
for (unsigned i = 0; i < (sizeof(chars)-1); ++i) {
unsigned j = rand() % sizeof(chars);
char tmp = result[j];
result[j] = result[i];
result[i] = tmp;
}
problem writing the result to a text file.
Your problem is that the character value 0 isn’t mapped to A. Rather, a character which will will be printed as A is equal to 65. You can see the full table here, if you ever need it.
Anyway, the code solution is simple.
Instead of
You can do:
(the -1 is because you numbered the letters from 1 to 26 instead o 0 to 25).