Instead of the non-informative
try using perror instead. It should tell you why the file can't be opened. Chances are that the program is looking in a different location that where the file is.
printf("Cannot open %s.\n",fname);
void main is only valid if you're on a freestanding implementation. Since you're learning C, this is highly unlikely. Use one of these:
And of course, return an integer value at the end.
int main(void) /* No arguments */
int main(int argc, char **argv) /* Command line arguments */