answersLogoWhite

0


Best Answer
Answer
  • I take it you are using some version of c,c++,visualC etc etc. One thing that is standard is pointers. A pointer is the address of a memory space that holds information in that specific space. By referencing the pointer in your code, you can print out that specific bit of information that the poiner is actually pointing to. Hope this helps
User Avatar

Wiki User

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

Wiki User

12y ago

An array of pointers is exactly what is says on the tin - an array which contains pointers to memory addresses.

If you were to create an array of ten integers like this:

int array[10];

This would create an array which you could directly access from the stack (memory allocated to the program by the Operating System).

However, if you wanted to create an array of pointers to integers, allowing for a more efficient use of memory, you could do this:

int *array = new int[10];

This dynamically allocates an array of 10 pointers to integers.

Comment:

This example is hardly an efficient use of memory. Not only are you declaring 10 integers, you are declaring a pointer, which uses slightly more memory than would otherwise be required by the first example. An array of pointers is more useful when the memory they point to is non-contiguous and the number of elements is dynamic rather than static. Even dynamic multi-dimensional arrays can be allocated in contiguous space and simple pointer arithmetic can be used to access any element, thus only one pointer is required for the entire array rather than separate arrays of pointers and pointer-to-pointer arrays for each dimension. While pointer arrays can often improve performance, it is always at the expense of memory consumption.

This answer is:
User Avatar

User Avatar

Wiki User

15y ago
  1. #include
  2. using namespace std;
  3. main()
  4. {
  5. int * add(int,int);
  6. int *ptr;
  7. int x,y;
  8. cin>>x>>y;
  9. ptr=add(x,y);//address of the result variable is assigned to ptr
  10. cout<<"result is"<<*ptr;
  11. }
  12. int *add(int a,int b)
  13. {
  14. int c=a+b;
  15. return(&c);
  16. }
  17. #include
  18. using namespace std;
  19. main()
  20. {
  21. int add(int,int);
  22. int (*ptr)(int,int);//declaring function pointer
  23. int x,y,result;
  24. cin>>x>>y;
  25. ptr=add //address of the function is assinged to ptr
  26. result=(*ptr)(x,y);
  27. }
This answer is:
User Avatar

User Avatar

Wiki User

11y ago

You point at the array the same way you would with an array of any pointer type, by using an additional level of indirection than is employed by the pointers in the array itself. In this case, the array contains pointer-to-function data types (with one level of indirection), thus you must use a pointer-to-pointer-to-function data type (with two levels of indirection) in order to point at the array itself.

Had the array contained pointer-to-pointer-to-function data types (where each pointer points to a separate array of pointer-to-function data types), then you'd use three levels of indirection, and so on.

You increase the level of indirection by placing an additional asterisk before the pointer's name when you declare the pointer. That is, one asterisk per level.

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

A pointer is a variable that stores a memory address. If the address is non-null (non-zero) that address can be dereferenced to access the value stored at that address.

Pointers are necessary when referring to objects allocated on the heap because objects on the heap have no name, they can only be accessed via their memory address (their actual identity). Resource handles and smart pointer objects allow access to heap-based objects in languages that have no concept of a "raw" pointer.

Pointers are also useful in that the same variable can be used to refer to different objects simply by changing the address stored in the pointer. This makes it possible to pass by reference in languages that only support pass by value semantics. Pointers are copied, but the since the value of a pointer is an address, it is the same as passing the address, by reference.

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

typedef void (*myfunptr)(void);

extern void fun1 (void), fun2 (void), fun3 (void);

myfunptr ptrs[] = {fun1, fun3, fun3};

ptrs[0]();
ptrs[1]();
...

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Nothing. You might have meant pointer-to-function.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Yes. A function can return a pointer...

const char* GetHelloString() { return "Hello!"; }

... returns a pointer to the string "Hello!".

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What do you mean by function to pointer?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How can you declare a pointer function?

*function();this declares a pointer function!


What is the difference bw function pointer and function of pointer?

function pointer is a variable that hold the address of any function which declared in the program but function pointer is the array of the function that accept the run time size of the function.


What is the difference between a function pointer and a pointer to a function?

A pointer to a function is the memory address that stores the address of a function, while the pointer itself is a function pointer.A pointer to a function might be defined as "int (*pf)(int, int);", while to actually point to the function, you would use a function pointer, such as "pf = &func;".


What does the pointer on a triple balance beam mean?

The function of a pointer tells you if you have the correct measurement or not. hope that helped!!:)xoxox &lt;3 -Demi


What is pointer variable explaine?

If you mean example, then it is argv, which is the second parameter of function main.


C program pointers to pointers examples?

Pointer to Pointer is a double pointer, denoted by (**). Pointer stores the address of the variable and pointer to pointer stores the address of a pointer variable and syntax can be given as int **ptr2ptr;


Pointer to pointer in c?

Usable. A prominent example is param argv of function main.


Function of pointer multi-tester?

TARUB


Which function is used to determine the position of the put pointer in a file in c plus plus?

The function ftell returns the position of the file pointer for a file.


A pointer to function which receives an int pointer and returns a float pointer?

float *(*funptr)(int *); float *fun (int *); funptr= fun;


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);


What is the datatype of the pointer returned by malloc function?

void