Hi,
while(((long)(1000*ratio*((long)clock()-(long)t0))%100)/1000)<Data_Read_Rate);
The above line is generating the following error: "Syntax Error before < token".
Why is this error coming up?
I use MINGW32 for development(GCC compiler).
Thanks...
Hi,
while(((long)(1000*ratio*((long)clock()-(long)t0))%100)/1000)<Data_Read_Rate);
The above line is generating the following error: "Syntax Error before < token".
Why is this error coming up?
I use MINGW32 for development(GCC compiler).
Thanks...
One paren is missing on the left. This will parse:
while ((((long)(1000*ratio*((long)clock()-(long)t0))%100)/1000)<Data_Read_Rate);
Aside from the parse issue:
Also, considering your use of the % operator, you may want to have the extra paren placed like so (I'm assuming ratio is not an integer), because the % operator requires integer operands:
while (((long)(1000*ratio*(((long)clock()-(long)t0))%100)/1000)<Data_Read_Rate);
(But does that make sense on a semantic level? Chop it up!)
Parenthisis are not matching. BTW, I would actually edit the code and break it up into multiple statements to make it more readable.
You have too many closing parenthesis.
Plus, your logic is so long and deep that I don't care to try and figure out what the code should be. Just that vim highlights the last ) in red, meaning it's mismatched. I suggest you consider using a few intermediate variables and simplifying the logic of that statement by spreading it out into a few lines instead of one.
You've too many Opening and closing parenthesis. If you're using visual studio, it will help you to match the opening and closing paranthesis/brace using Ctrl+'[' and Ctrl+']' key presses
Another suggestion is group and divide it into multiple lines by maintaining the readability of expressions. Also try to give space between subsequent parenthesis by to logically group the expressions.
Because the compiler gets as confused about your code as the human reader? [shudder]
Spaces and line breaks are for free, and add nicely to readability.
while ( ( (long)( 1000 * ratio * ( (long)clock() - (long)t0 ) ) % 100 ) / 1000 ) < Data_Read_Rate );
You could do away with the (long) casts of clock() and t0, too (assuming they're both int ). Casting them before substraction won't change the result. To make the whole calculation in long, it'd be sufficient to make one of the arguments long - and the shortest way to do that is casting the literal 1000:
while ( ( ( 1000l * ratio * ( clock() - t0 ) ) % 100 ) / 1000 ) < Data_Read_Rate );
Hmmm... wait. You take something, modulo 100 (yielding a number between 0 and 99), and then divide by 1000? Your result is always 0...
Oh, and you forgot to match your parenthesis. ;-)
As mentioned previously your parentheses are mis-matched.
With expressions like this is it nearly always better to work with some interim variables to simplify the statement. However the following tips may help.