hello, i am using keil uvision 4.0 for my 8051 projects.i am getting an error whenever i use the pre defined word 'else' in my code. ex:
if(an1==1)
{
LED1=1;
LED2=1;
else //at this point//
LED1=0;
LED2=0; }
it shows an error C141. Can you please help me out..
sure, but your problem show such a lack of understanding the basic C concepts, not to mention that you are unable to follow instructions (re posting code), that helping you would make you come back with an equally basic problem in a few minutes
get a C book, study it
Erik
Learn how to use/apply compound statements properly.
if(an1==1) { LED1=1; LED2=1; } // Brace here else { // Brace here LED1=0; LED2=0; }
I had the exact same problem when I started!!!!
That was the help I needed. Nice not to get the 'teach a man a fish' crud.
I see no one did teach you to fish - it isn't "teach a man a fish".
But more importantly: do you think it is a bad idea to tell someone that they should spend some time with a book about the C language? In what way is that bad? You prefer that people learn without books - asking about every single aspect of the language on a forum? But how can someone ask about a concept they don't even know exists?
"Nice not to get the 'teach a man a fish' crud."
Yeah, learning the language -- that's so lame.
We could fix your syntax errors faster if you publish your code to a public repository for us to directly edit.
Man, do you suffer from tunnel vision?
What I'm saying is that I once got caught on the very same problem. I had some books, but nothing seemed to make sense. Then someone told me the same like explained here. It was the nudge I needed so my learning could commence and continue and progress.
If some dumb-ass fool had just said 'read the manual', I might have just given up. But I was lucky. Someone gave me that nudge and I am eternally grateful to them. Without that, I would possibly have ended up in a dead end, pretentious job. I could even have shamed my family and become ... a ... consultant (weep).
A least I'm sagacious enough to recognize when Please read the manual isn't the appropriate answer.
And for what it's worth, I admire your keen mental discernment and good judgment that you show in such matters.
View all questions in Keil forum