It is due to a typographical error. This line:
Code:
if ((openedfile = fopen(filename, "r") == NULL)
should be:
Code:
if ((openedfile = fopen(filename, "r")) == NULL)
The reason is that the compiler is interpreting the expression as:
Code:
openedfile = fopen(filename, "r") == NULL
EDIT:
Now, the fopen(filename, "r") == NULL binds tighter than the assignment, but the result of this subexpression is a boolean value, an integer. This temporary integer is then assigned to openedfile, but that mean you are assigning an integer to a pointer without a cast - which is precisely what the "extra" pair of parentheses was supposed to avoid. Then, the compiler goes on to find that there is a missing closing parenthesis, hence the parse error.