In my code below
#include<stdio.h>
int a;
a=3;
void main(){
printf("%d",a);
}
Why am I getting the warning,
a.c:3:1: warning: data definition has no type or storage class [enabled by default]
In another case, when I have
#include<stdio.h>
#include<stdlib.h>
int* a;
a=(int*)malloc(sizeof(int));
void main(){
*a=3;
printf("%d",a);
}
I get error: conflicting types for ‘a’
, and also warning as
warning: initialization makes integer from pointer without a cast [enabled by default]
Why?