Q:

What is the difference between (char*)'r' and "r"?

I'm confused at the differences between (char*)'r' and "r", and perhaps (char*)"r", if that's different from "r".
int main () {
    char fileNameOriginal[MAXLINE] = "test.txt";
    openFile(&fp, fileNameOriginal, (char*)'r');
}
openFile(FILE **fp, char fileName[], char* mode) {
    *fp = fopen(fileName, mode);
}

This format for passing the mode argument of fopen will not cause a warning/error by my eclipse IDE. However, the file will not be read correctly. On the other hand, passing "r" or (char*)"r" will generate a correct reading.

A:

(char*)'r' is a an attempt to convert the int constant 'r' to a char* pointer. That actual value associated with 'r' depends on the encoding your system uses.
When the library function attempts to dereference that pointer, the program behaviour will be undefined.
"r" on the other hand is a char[2] type, which will decay to a char* pointer required by the function.
It's difficult for an IDE to issue a warning for the incorrect case; and remember that one of the tenets of C is that you are assumed that you know what you're doing!

A:

In C all character literals are really int values. For systems using the ASCII encoding system (the vast majority) then 'r' is equal to 114.
So your call is really openFile(&fp, fileNameOriginal, (char*)114);, and even a beginner should see that it's not really correct.

