3,885 views

4 Answers

Best answer
4 4 votes

int (*q(char *))[] means q is a function that takes char * as argument and returns a pointer to an array of integer.

Option (C) means q is a pointer to a function that takes char * as argument and returns an array of integers.

So, None of the above is correct.

• selected by
4 4 votes

1. int (*q(char*)) = q is a  function which take character pointer as argument and return  pointer to Integer.

2. int *q(char*)[] = declare q as function (pointer to char) returning array of pointer to int

3. int (*q)(char*)[] = declare q as pointer function (pointer to char) returning array of int

Reffer :http://cdecl.org/

Correct would be : 

int (*q(char *))[] = declare q as function taking character pointer as argument and returning pointer to array of  int

2 2 votes

Ans D)

C)Here q is a $\color{blue}{ pointer}$ $\color{blue}{ to}$ $\color{blue}{ a}$ $\color{blue}{ function}$ passing a pointer to a charecter as argument which returns array of integer .

B)q is a function passing passing a pointer to a charecter as argument which returns $\color{blue}{ array}$ $\color{blue}{ of}$ $\color{blue}{ integer}$ $\color{blue}{ pointer}$

https://gateoverflow.in/35193/regarding-pointers

http://c-faq.com/decl/spiral.anderson.html

https://gateoverflow.in/58327/doubt-on-array-of-pointers

• edited by
0 0 votes
answer is A as  its a function that accepts pointer to character as argument i.e. q(char *) and returns a pointer to integer array i.e. int *().
Position:
Show:

Related questions

8 8 votes
1 1 answer
266
266 views
GO Classes asked Jun 19
266 views
What is the output of the following code?#include <stdio.h void fun(int a[], int *p) { a = a + 5; *(p + 2) = *(p + 2) + 10; p++; *p = *p + 1; } int main() { int arr[] =...
6 6 votes
1 1 answer
217
217 views
GO Classes asked Jun 19
217 views
What is the output of the following code?#include <stdio.h int main() { int arr[] = {10, 20, 30}; int *p = arr; printf("%d %d", *p, *(arr + 2)); return 0; }$\texttt{10 20...
8 8 votes
1 1 answer
225
225 views
GO Classes asked Jun 6
225 views
What is the output of the following code?#include <stdio.h void change(int *p, int *q) { *p = *p + 4; *q = *p + *q; p = q; *p = *p - 3; } int main() { int a = 6, b = 10; ...
8 8 votes
1 1 answer
231
231 views
GO Classes asked Jun 6
231 views
What is the output of the following code?#include <stdio.h int main() { int a = 8, b = 12; int *p = &a; int *q = &b; *p = *p + *q; q = p; *q = *q - 5; printf("%d %d", a, ...