answersLogoWhite

0


Best Answer
Please ask just one question at a time!
Question 1:

How do you declare an array of three pointers to chars?

How do you declare an array of three char pointers?


Note: both of these questions are merely alternative wordings for the same question.


Answer 1:

char * a[3];


Question 2:

How do you declare a pointer to an array of three chars?


Answer 2:

char a[3]; // an array of three chars

char * p = a; // a pointer to an array of three chars


Question 3:

How do you declare a pointer to a function which receives an int pointer?


Answer 3:

#include


// some functions we can point at:

void func_1(int * p){}

void func_2(int * p){}

// note: all functions we wish to point at with the same

// pointer must have the same signature.


int main()

{

int* p = NULL; // instantiate an int pointer

void (*pFunc) (int*); // declare a function pointer

pFunc = func_1; // point to func_1

pFunc(p); // call func_1 via function pointer

pFunc = func_2; // point to func_2

pFunc(p); // call func_2 via function pointer

return(0);

}


Note that the brackets in the function pointer declaration are required. If you omit them, you will end up with a standard function declaration that returns a pointer to void, resulting in a compiler error.





User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

15y ago

int main()

{

char *array[3]; // This declares an array of type char*of size 3

// Declare two random chars

char example0 = 'X';

char example1 = 'Y';

// You can use the char* array elements just like any regular char*

array[0] = example0;

array[1] = example1;

printf("array[0] = %c, array[1] = %c\n", array[0], array[1]); // Prints X, Y

array[0] = example1;

array[1] = example0;

printf("array[0] = %c, array[1] = %c\n", array[0], array[1]); // Prints Y, X

return 0;

}

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

Typedef the function signature then create an array of pointers of that type.

char* func1() {/*...*/}

char* func2() {/*...*/}

char* func3() {/*...*/}

typedef char* (*func_ptr)();

func_ptr func_array[3];

int main()

{

func_array[0] = &func1;

func_array[1] = &func2;

func_array[2] = &func3;

/*...*/

return 0;

}

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

char* my_array[3]; /* an array of three pointers to char */

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

char * p[3];



This answer is:
User Avatar

User Avatar

Wiki User

14y ago

char* a[3]; char* b[3]; char[3] *c; void(*d)(int*); Note that these are definitions. To make these declarations only, use the keyword 'extern'.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

char c[3]; //array of 3 chars

char * p; //pointer of type char

p=c; //point the pointer to the base of char array

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

char *p[3];

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you declare an array of N pointers to functions returning pointers to functions returning pointers to characters?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do declare function pointer having two integer parameters and returning integer pointers?

// declare a function int* function(int, int); or int* (function)(int, int); // declare a pointer to a function int* (*pointer_to_function)(int, int);


How do you declare an array of five pointers to chars?

char *p="ragav"


How do you declare functions?

datatype function_name() { }


How do you declare a functions?

public void throwRock() { }


How do you declare gotoxy?

You don't declare library functions. Simply include conio.h. For details use the built-in help.


How do doctors declare death?

The doctor determines if a patient has a pulse, if the patient are breathing and if he or she has any brain functions. If all three bodily functions are absent,a doctor can declare the person dead.


What is out of scope in returning objects in java?

if u declare variable in method & tray to use this variable outside the method then it is out of scope


How you declare class scoped variables and member functions?

To scope class members to the class (rather than to instances of the class), declare them as static members of the class. Static members are accessible even when no instances of the class exist. As such, static member functions do not have access to a 'this' pointer, unlike ordinary (nonstatic) member functions.


What are the function of header files?

They declare library functions They contain macro definitions They contain type definitions


Can you declare a function in the body of another function in c language?

yes, we can not declare a function in the body of another function. but if we declare a function in the body of another function then we can call that very function only in that particular function in which it is declared; and that declared function is not known to other functions present in your programme. So if a function is required in almost all functions of your programme so you must declare it outside the main function i.e in the beginning of your programme.


How to declare near and far pointers in C?

It used to be a good question 30 years ago. Right know you don't have to know anything about near and far pointers; but if you still use a 16-bit compiler, select 'Large Model' (or 'Huge Model'), and forget 'near' and 'far'


What is the difference between array and string of array?

When we declare an array of characters it has to be terminated by the NULL , but termination by NULL in case of string is automatic.