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 3 of 5.

Sushovan said:   10 years ago
Parameters will not be static. Its not allowed.

Sujan said:   9 years ago
What would be the answer if it wasn't static?

Praju said:   9 years ago
Can anyone please explain question with the correct program?

Avinash said:   9 years ago
What kind of function is this?

int *check();

I mean what does the * sign denote here?

Amit said:   8 years ago
Static is not allowed.

Barath said:   1 decade ago
Acc to ANSI C standards we can not pass variables which are specified with storage class to function as arguments except the variables with the keyword register.

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

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

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

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

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.


Post your comments here:

Your comments will be displayed after verification.