In VC ++ 6.0, there is no compilation error, but an error is reported when running to a certain step. If the problem persists, step-by-step debugging is successful. Very confusing!
Baidu later found that a problem occurred while declaring the variable.
Then I put all the variable declarations in front of them, and it would be normal ~~~
In Baidu, the additional gains are recorded as follows:
C2143: syntax error: Missing 'token1' before 'token2'
C2144: syntax error: Missing 'Token' before type 'type'
If the above error occurs, the solution is to put all the data statements into executableCodeBefore.
The following code provided by msdn produces such an error.
# Include <stdio. h>
Void main (void)
{
Int I;
Printf ("Hello World/N ");
Int J;
}
This error may occur when the variable declaration is placed after the executable code. And this is inK & R CBut inANSI C.
Note: the author of the C programming language (K & R) is also the father of C language. K & r c is often used for comparison with ansi c.
In ansi c or C ++, variables can be defined at any time in executable code, but cannot be defined in K & r c.
I heard that when writing C in Vs, if you use for (INT I = 0; I ++; I <10), and your file name is. c. This error will also occur. You can setChange. C to. cpp.