C Programming - Pointers - Discussion

Discussion Forum : Pointers - Find Output of Program (Q.No. 8)
8.
What will be the output of the program ?
#include<stdio.h>
int *check(static int, static int);

int main()
{
    int *c;
    c = check(10, 20);
    printf("%d\n", c);
    return 0;
}
int *check(static int i, static int j)
{
    int *p, *q;
    p = &i;
    q = &j;
    if(i >= 45)
        return (p);
    else
        return (q);
}
10
20
Error: Non portable pointer conversion
Error: cannot use static for function parameters
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
50 comments Page 5 of 5.

Sarang S. Metkar said:   1 decade ago
Can anyone tell me what is d meanining of "timid" ?

Gopi said:   1 decade ago
Static variables will never change its value but parameters used in function should suppose to have different values.

Ramesh said:   1 decade ago
@apurva nigam.

Remember that, like any other local variable, a static variable cannot be referred to outside the function.

Apurva Nigam said:   1 decade ago
@Mani:
Here the function is NON STATIC. so does it mean it cant access static variables???

What if both(ie parameters and function) were static??
Then the code would be correct??
Or
@Nikhil:
u mean Parameters can never be static whether its a STATIC or NON STATIC function???

Mani said:   1 decade ago
Static member function cannot access the non static members.

Tim said:   1 decade ago
This is another C# trick, not ANSI C. No one should use C# unless they want to write non-portable code.

Sindhu said:   1 decade ago
Static means those variables are initialized as 0,,so static can never be passed as function arguments...

Nikhil said:   1 decade ago
Parameters are never static.. its not allowed

Shrinivas said:   1 decade ago
Please, Can any one explain what kind of function is this?

int *check(static int i, static int j)

Sachin said:   1 decade ago
Can any one explain this one please?


Post your comments here:

Your comments will be displayed after verification.