Link to home
Start Free TrialLog in
Avatar of cwchan80
cwchan80

asked on

Problem on compiling *.c source file when using fpt = fopen() on VC++.

I am having a problem on compiling C source file in Visual C++ 6.0 when using FILE *. Suppose I have the following source file:

// test.c

#include <stdio.h>
main()
{
     FILE *fpt;
     fpt = fopen("source.c", "r");
     int i;
}

Whenever I use FILE *fpt and fopen it, I will get errors, such as:

error C2143: syntax error : missing ';' before 'type' (refer to the line of "int i")


If I change the source file's extension to "cpp" and recompile it, the problem solved. How can I keep the "c" extension and let the FILE * works in VC++?

Thanks and hope to hear from you ASAP.
ASKER CERTIFIED SOLUTION
Avatar of peter_sheynkman
peter_sheynkman

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial