Hello everybody,
I have seen the operator %= used in a code meant for Keil C. Can somebody explain me its purpose? Thanks.
www.8051projects.net/.../forum_viewtopic.php
char getchar() { volatile char c; while(RxInChar == RxOutChar); ES = 0; /* Disable Interrupts */ c = RxBuffer[ RxOutChar++ ]; RxOutChar %= BUF_SIZE; ES = 1; /* Enable Interrupts */ return( c ); }
RxOutChar %= BUF_SIZE;
is equivalent to
RxOutChar = RxOutChar % BUF_SIZE;
where % is the modulus operator
Thank you Walter Conley.
Actually after posting, I studied the code again & understood the meaning of the code, but was still wondering about the exact operator. THANK YOU VERY MUCH.
Note that this is basic, standard 'C' syntax - nothing specifically to do with Keil or embedded or the 8051...
Really sorry about that. I am new to C as well as to Keil.
I am new to C C51 is just about the lousiest platform there is to learn C on.
Get a "teach yourself C" book (I recommend Kochan: "programming in ANSI C") and a (free) PC C compiler and start learning.
Make sure you get a C book, not a C++ book if you want to move forward with the '51
Erik
View all questions in Keil forum