We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
i am facing error C141: syntax error near '}'
my program is given below:
#include<reg51.h> void main ( ) { int x; while (1) { P1 = 0x00 ; for (x=0 ; x<=5000 ; x++) P1 = 0xFF ; for (x=0 ; x<=5000 ; x++) } }
any one can help me how to solve it
Yes, I'm fairly good at reading oneliners.
But the important thing here is that the OP have issues with C scoping rules - what forms a complete for() loop.
And such a debate would be many times easier if the OP had posted the code in a way where the code had corresponded with his views on scoping rules.
Not having read the posting instructions, makes it impossible to know what the OP thought formed a for loop. But it seems logical to assume that the OP thought a for() alone on same line would be enough - missing that the compiler will continue to following lines looking for a statement or block.
The important thing is that this type of questions should have contained not just a part of an error message, but the compilete error message. That error message would then indicate a line number too. And if the OP had done what a smart poster would have done - marked which line the error message mentioned - it would have been even easier to have the OP see why the message said what it said.
I really don't care what indentation styles other people selects, as long as they follow "my" indentation style when doing changes to "my" code. But for a beginner, it is totally important to be strict with a code layout where it is 100% visible what binds to what - and where blocks and statements ends.
Another interesting thing that happens when people ignore the proper posting instructions, is that source code instructions happens after end of one-line comments, since a web browser have no idea that the original line breaks was important. So it can be impossible to know what source lines was commented away by the poster, and what source lines just looks commented away in the posting.
In the end, posters often save 30 seconds by not checking the posting instructions. Then they waste minutes for the people who could possibly help. Then they end up having wasted hours or days because they don't get the help that was available.
Not checking posting instructions to save time is just ass efficient as premature optimization of code - it normally ends up costing a lot.
In the end, posters often save 30 seconds by .... Then they waste minutes for the many people who could possibly help.
minutes * many versus to seconds * one
Erik