C++ Trivia
Friday, April 6, 2007
Can some one tell the output using different compiler (especially VC++) and explain the reasoning too?
5 points to you if you find the correct answer in first go.
-----------------------------------------------------------
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
int Buffer[16];
int i = 10;
switch (i)
{
case 9:
int Buffer[8];
break;
case 10:
printf("The number of elements in buffer is %d",s izeof(Buffer)/sizeof(int));
getchar();
break;
}
return 0;
}
----------------------------------------------------------------------
5 points to you if you find the correct answer in first go.
-----------------------------------------------------------
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
int Buffer[16];
int i = 10;
switch (i)
{
case 9:
int Buffer[8];
break;
case 10:
printf("The number of elements in buffer is %d",s izeof(Buffer)/sizeof(int));
getchar();
break;
}
return 0;
}
----------------------------------------------------------------------
| | |