The Concept of a Developer Pointer: [Essay Example], 1069 words GradesFixer
exit-popup-close

Haven't found the right essay?

Get an expert to write your essay!

exit-popup-print

Professional writers and researchers

exit-popup-quotes

Sources and citation are provided

exit-popup-clock

3 hour delivery

exit-popup-persone
close
This essay has been submitted by a student. This is not an example of the work written by professional essay writers.

The Concept of a Developer Pointer

Download Print

Pssst… we can write an original essay just for you.

Any subject. Any type of essay.

We’ll even meet a 3-hour deadline.

Get your price

121 writers online

blank-ico
Download PDF

Definition

A pointer variable is a variable that keeps addresses of memory locations. Like other data values, memory addresses, or pointer values, can be stored in variables of the appropriate type. A variable that stores an address is called a pointer variable, but is often simply referred to as just a pointer.

The definition of a pointer variable, ptr, must specify the type of data that ptr will point to. Here is an example: int *ptr; The asterisk before the variable name indicates that ptr is a pointer variable, and the int data type indicates that ptr can only be used to point to, or hold addresses of, integer variables. This definition is read as “ptr is a pointer to int.” it is also useful to think of *ptr as the “variable that ptr point to.” with this view, the definition of ptr just given can be read as “as the variable that ptr points to has type int.’ because the asterisk (*) allows you to pass from a pointer to the variable being pointed to, it is called the indirection operator. It is the responsibility of the programmer to keep track of what type of data is stored in each memory location. The data might be a number or some text (which is just a sequence of numbers, of course) or it might be an address of another location or possible an address of an address and so forth.

There are also some high level languages – un typed languages – that operate in the same way; Forth and BCPL are examples that come to mind. The majority of high level languages support data typing to a lesser or greater extent. This means, in effect, that the programmer specifies that a variable contains a specific type of data and the language only allows appropriate operations on that variable. Advantage of using pointers is efficient in handling Arrays and Structures, Pointers allow references to function and it helps in passing of function as arguments to other functions, it reduces length of the program and its execution time as well and it allows C language to support Dynamic Memory management.

WHAT IS THE PURPOSE OF DEVELOPER POINTERS

Pointer and array

I learned earlier in before chapter that an array name, without brackets and a subscript, actually represents the starting address of the array. This means that an array name is pointer. Program next page by showing an array name being used with the indirection operator. Remember, array elements are stored together in memory, as illustrated in picture below. It make sense that if numbers is the address of numbers [0], values could be added to numbers to get the addresses of the other elements in the array. In other words, if you add one to number, you are actually adding 1 * sizeof (short) to numbers. If you add two to numbers , the result is numbers +2* sizeof (short), and so on. This conversion means that an element in an array can be retrieved by adding its subscript to a pointer to the array. Pointer to pointer:

Pointers are used to keep the address of other variables of similar data type. But if you want to store the address of a pointer variable, then you again need to store it. Thus, when one pointer variable stores the address of another pointer variable, it is known as Pointer to Pointer variable or Double Pointer. Here, we have used two indirection operator(*) which stores and points to the address of a pointer variable i.e, int *. If we want to store the address of this (double pointer) variable p1, then the syntax will become. For example, int ***p2.

Pointer to structure

We also have array of structure variables. And to use the array of structure variables readily, we use pointers of structure type.. To access members of structure using the structure variable, we used the dot . Operator. But when we have a pointer of structure type, we use arrow -> to access structure members. Pointer to arithmetic: The pointer variables changed with mathematical statements that perform addition or subtraction. This is demonstrated in program next page. The first loop increments the pointer variable, stepping it through each element of the array backwards.

Not all arithmetic operations may be performed on pointers. For example, you cannot use multiplication or divison with pointers the following operations are allowable: the ++ and – operators may be used to increment or decrement a pointer variable. An integer may be added to or substrated from a pointer variable. This may be performed with the + and- operators. And a pointer may be substracted from another pointer. a few examples and understand this more clearly. int*i; i++; increment it, it will increment by 2 bytes because int is also of 2 bytes. float*i; i++; increment it, it will increment by 4 bytes because float datatype is of 4 bytes. double*i; i++; Similarly, in this case, size of pointer is still 2 bytes. But now, when we increment it, it will increment by 8 bytes because its data type is double.

Pointer to functions

Pointer as a function parameter is used to hold addresses of arguments passed during function call. This is also known as call by reference. When a function is called by reference any change made to the reference variable will effect the original variable. It is possible to declare a pointer pointing to a function which can then be used as an argument in another function. A pointer to a function is declared as follows, type (*pointer-name)(parameter);. Here is an example: int (*sum)(); int *sum();A function pointer can point to a specific function when it is assigned the name of that function. Int sum (int, int); int (*s)(int, int); s=sum;

Here s is a pointer to a function sum. Now sum can be called using function pointer s along with providing the required argument values. s(10,20);. ; increment it, it will increment by 2 bytes because int is also of 2 bytes. i i++; pointer to integer: It is commonly to store the value of a pointer (i.e. an address) in an “ordinary” variable – like an unsigned integer. An example of where this might be done in fixed is in device. Here is an example: unsigned normal; unsigned *pointer; pointer = &normal; normal = (unsigned)pointer; This would result in the variable normal containing its own address.

Remember: This is just a sample from a fellow student.

Your time is important. Let us write you an essay from scratch

100% plagiarism free

Sources and citations are provided

Find Free Essays

We provide you with original essay samples, perfect formatting and styling

Cite this Essay

To export a reference to this article please select a referencing style below:

The Concept of a Developer Pointer. (2018, September 27). GradesFixer. Retrieved October 28, 2020, from https://gradesfixer.com/free-essay-examples/the-concept-of-a-developer-pointer/
“The Concept of a Developer Pointer.” GradesFixer, 27 Sept. 2018, gradesfixer.com/free-essay-examples/the-concept-of-a-developer-pointer/
The Concept of a Developer Pointer. [online]. Available at: <https://gradesfixer.com/free-essay-examples/the-concept-of-a-developer-pointer/> [Accessed 28 Oct. 2020].
The Concept of a Developer Pointer [Internet]. GradesFixer. 2018 Sept 27 [cited 2020 Oct 28]. Available from: https://gradesfixer.com/free-essay-examples/the-concept-of-a-developer-pointer/
copy to clipboard
close

Sorry, copying is not allowed on our website. If you’d like this or any other sample, we’ll happily email it to you.

    By clicking “Send”, you agree to our Terms of service and Privacy statement. We will occasionally send you account related emails.

    close

    Attention! this essay is not unique. You can get 100% plagiarism FREE essay in 30sec

    Recieve 100% plagiarism-Free paper just for 4.99$ on email
    get unique paper
    *Public papers are open and may contain not unique content
    download public sample
    close

    Sorry, we cannot unicalize this essay. You can order Unique paper and our professionals Rewrite it for you

    close

    Thanks!

    Your essay sample has been sent.

    Want us to write one just for you? We can custom edit this essay into an original, 100% plagiarism free essay.

    thanks-icon Order now
    boy

    Hi there!

    Are you interested in getting a customized paper?

    Check it out!
    Having trouble finding the perfect essay? We’ve got you covered. Hire a writer

    GradesFixer.com uses cookies. By continuing we’ll assume you board with our cookie policy.