Pointer questions in c

c, declaration, pointers

Solution

A function that takes a double as input and returns a `char` pointer would look like this:

char * foo(double arg);

Where `arg` is your input double, `foo` is the name of the function, and `char *` is the return type, a char pointer.

char (*foo)(double arg);

Declares a function pointer to a function that takes a double (`arg`) and returns a `char`.

Your attempt at creating an array is missing a variable name. And there are two different ways to do this...

int * array[10];

This declares an array with 10 indexes that holds `int *`, int pointers.

int (*array)[10];

This declares a pointer to an array of ints with size of 10.

Problem

Quick question about C programming. I haven't taken a course on it, but was reading online about pointers and the various notations used. Does the following line result in an array of 10 pointers to integers, or a pointer to an array of 10 ints? ``` int *x[10]; ``` Also does the following result in a function that takes a double as input and returns a pointer to a character? ``` char (*f) (double a); ``` Thanks in advance! Edit: Typed the first line of code incorrectly.

Original source