Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   variable scope (http://www.go4expert.com/forums/variable-scope-t9631/)

mundrapiyush 28Mar2008 17:04

variable scope
I was just playing around with pointers. In the following code what i feel is once check is executed the variable i and j must get killed as soon as the function returns. So actually we should not be able to collect it in the variable 'c' inside the main. Guys please tell whether my justification is right or wrong ?

int* check(int,int);

void main()
        int *c;
        c = check(10,20);
        printf("\nc = %d",*c);

int* check(int i, int j)
        int *p, *q;
        p = &i;
        q = &j;
        if(i >= 45)

All times are GMT +5.5. The time now is 03:35.