answersLogoWhite

0

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

12y ago

What else can I help you with?

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.