Tuesday, November 1, 2011

What's the problem

No matter how much you think you know C/C++ there are things that you can always miss if you are not thorough. This small program is one of them. Can you tell me how many times "Java Rules" is printed ?
#include <stdio.h>

  int main()
  {
   int counter = -1;
   
   while( counter < sizeof(int))
   {
     printf("Java Rules!! \n");
     counter++;
   }
    
   return 0;
  }
The answer is none, because the fact is Java doesn't Rule :P
Alright alright, the reason is sizeof operator returns unsigned int :)