Hi Aurel,
Re. C loops1. In C, "empty"
while (........); is used to set up a loop whose entire code can be expressed in between the condition statement parentheses and thus won't need additional code lines in the "body" of the loop proper.
Thus
while ((NextChar = getchar()) == ' ');means
- get a char (in fact, not a char-long string but rather a numeric byte) from stdin
- assign it to NextChar
- check if the assignment returns literal 32 (unlike BASIC, matching C parentheses embracing an assignment define the scope that returns the value of this assignment) where = denotes assignment, == denotes equality, and ' ' with a space in between denotes numerical 32 and is equivalent to BASIC Asc(" ")
- loop back if the value of assignment is equal to 32, otherwise break (i.e. stop looping)
2. Conversely,
for (;;) ........ ; is often used to set up a loop in which everything occurs within the loop body rather than in its declaration, e.g.
int i = 0;
for (;;) {
if (++i == 5) break;
}whereby the loop is going to break (it means the code will exit from the loop) on its 5th iteration.
3. Summing up, C language "empty"
for (;;);,
while(1); and
do{}while(1); would all mean "loop forever". Exactly which "infinite loop" the programmer is going to use in their code depends entirely on their coding habits.
Re. C sourcesNo problem, please post the C picture and we will try to turn it into usable O2 code. I suppose you'd also like to use it for parsing a memory string rather than the console buffer, wouldn't you? And no, the code isn't complete as it lacks the executable's
main() function or its O2 global level code equivalent. But we can manage to write it ourselves if we know exactly what you're going to parse -- the console's keyboard input buffer or a memory string.