int main()
{
int j=97;
char arr[4]="Abc";
printf(arr,j);
getch();
return 0;
}
this code gives me a stack overflow error why?
But if instead of printf(arr,j)
we use printf(arr)
then it prints Abc.
please tell me how printf
works , means 1st argument is const char*
type so how arr is
treated by compiler.
sorry! above code is right it doesn t give any error,I write this by mistake. but below code give stack overflow error.
#include <stdio.h>
int main()
{
int i, a[i];
getch();
return 0;
}
since variable i take any garbage value so that will be the size of the array so why this code give this error when i use DEV C++ and if I use TURBO C++ 3.0 then error:constant expression required displayed. if size of array can t be variable then when we take size of array through user input.no error is displayed. but why in this case.