N
niklaus
Hi,
I have seen that the following code compiles in some environments
like devc++ but fails on some env's like gcc on linux.
Can someone tell if "int *au=malloc(sizeof(int)*10);" is a constant
expression and can be used in global namespace/file scope.
Which part of the standard says or describes this .
#include<stdio.h>
#include<stdlib.h>
int *au=malloc(sizeof(int)*10);
int main()
{
if(au==NULL)
printf("memory not allocated\n");
else
printf("memory allocated\n");
return 0;
}
Thank you,
Nik
I have seen that the following code compiles in some environments
like devc++ but fails on some env's like gcc on linux.
Can someone tell if "int *au=malloc(sizeof(int)*10);" is a constant
expression and can be used in global namespace/file scope.
Which part of the standard says or describes this .
#include<stdio.h>
#include<stdlib.h>
int *au=malloc(sizeof(int)*10);
int main()
{
if(au==NULL)
printf("memory not allocated\n");
else
printf("memory allocated\n");
return 0;
}
Thank you,
Nik