tags:

views:

277

answers:

2

The last line in the following line keeps on generating the " warning C4552: '<=' : operator has no effect; expected operator with side-effect" error, but I don't see any fault in it...

void countDays(void) {
int i=0;
if (birth_month == 2 && birth_day <= 28) {
 for ( i <= what_birthday ){
+12  A: 

You're using the wrong syntax for the for loop in the code you posted, did you mean something like this?

for (; i <= what birthday; ++i) {...

If you didn't care about incrementing i after every iteration, you could use a while loop instead.

while (i <= what_birthday) { ...

The code shouldn't have compiled at all without the semicolons. You get that warning for things like:

for (i <= what birthday; ++i;)

Because while it is valid code, it's probably not what you intended.

Firas Assaad
+2  A: 

This code is equivalent:

void countDays(void) { 
int i=0; 
if (birth_month == 2 && birth_day <= 28) { 
{

you probably meant while instead of for.

soru