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
I would hazzard a guess that the OP is fairly new at programmingM also new at following instructions?
someone familar with C would (and should) be able so, when helping others using your free time you shall just do more work than is needed because the one asking can't follow directions? Even something as small as what triggered this takes quite a bit longer to figure out when not formatted
It also tires me to see the self proclaimed style police kick off about the small things and miss the big things. What does "following directions" (use pre ...) have to do with 'style'?. Are you saying that "I can't read your code" is not a valid reason to "miss the big things". How can you catch the big things if you can't read the code?
Erik
Even something as small as what triggered this takes quite a bit longer to figure out when not formatted
With all due respect, the time it takes is going to depend upon the skill set and experience of the person viewing the code. For example, i seem to have picked up a reputation for quickly seeing spelling mistakes and typos in text that others frequently miss. Yes Erik, your posts frequently show up on my radar!
Are you saying that "I can't read your code" is not a valid reason to "miss the big things".
Not at all. I was trying to say that being fixated with the small things at the expense of the big things is a particularly dumb thing.
"I was trying to say that being fixated with the small things at the expense of the big things is a particularly dumb thing."
Not when the little thing is a ';'.
But what is your view on the first for() loop in the posted code? Did the OP intend it as a empty for loop for a delay? Or a loop that should perform multiple writes of 0xFF to the port? Is there a way we can know, without seeing the code complete with the original indentation? Does it make a big difference in the result, when running the code?
By the way - compare posting time of my first answer with the creation time of this thread. And remove time for writing the text. I obviously can't have spent too much time on that mess, to pinpoint the issues. But does that make it less of a mess, because of the lack of indentation?
But why can you not use the correct formatting so we get to see a properly intended source code? Didn't you check the information directly above the message input box?
Back to your - very hard to read - code: What should a for loop do if you have nothing for it to do? Can a for loop be totally without statement - what does your C programming book say?
Another thing - what use is it to make 5001 assigns of P1 = 0xFF directly after each other? Exactly how do you think P1 = 0xFF interacts with the for loop?
Pers reply quoted above DOES inform the OP what the problem is (I guess that qualifies as the "big thing")
and you react to the comment about missed formatting (I guess that qualifies as the "small thing")
now you post I was trying to say that being fixated with the small things at the expense of the big things is a particularly dumb thing I think the pot is calling the kettle black