file1.c
int b=2;
void func(){
int c=10;
static int d=10;
int *cp=&c;
}
main.c
#include <stdio.h>
#include <stdlib.h>
extern b;
extern *cp;
int main()
{
int a=1;
printf("a=%d\nb=%d\n",a,b);
printf("c=%d\nd=%d\n",c,*cp);
return 0;
}
I couldn't able to access local variable 'c' from other file using pointe '*cp' as well. I know by default we can access the functions from other files without using extern keyword but how to access the local variables and static variables present inside those functions ?
Aucun commentaire:
Enregistrer un commentaire