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
In this case, we would have liked to see if the OP wrote code looking like (not too likely, since it gives a silly result):
void main ( ) { int x; while (1) { P1 = 0x00 ; for (x=0 ; x<=5000 ; x++) P1 = 0xFF ; for (x=0 ; x<=5000 ; x++) } }
Or (still same silly result):
or (showing misunderstanding of what ends a for() statement - or a copy/paste error):
The missing semicolon on the second for() loop indicates that the OP might have written the code as in the third example. So assuming the for() loop could handle itself, and that the P1 = 0xFF assignment would happen after the loop was done.
Or maybe the OP did write code like:
void main ( ) { int x; while (1) { P1 = 0x00 ; P1 = 0xFF ; } }
And then added the for() loops when noticing that the assigns directly after each other was too fast. And then did a copy/paste of a line with a missing ';' and couldn't understand why the first for() wasn't flagged as broken but the second was.
In the end - this is a specific case where the indentation would have told us more - even if we are able to read the one-liner.