answersLogoWhite

0


Best Answer

A pointer in C is the address of a variable or function.

The advantages of a pointer over using normal variables are:

If you pass the pointer to a variable to a function, then that function can modify the value of the variable directly; for example, suppose you want a function to convert a string to lower case. If pointers are not available, then a function call would look like this (in BASIC):

NewString = ToLower("This Is A String")

What the BASIC compiler does is make a copy of the "This Is A String" string, pass it to the ToLower() function and return a copy back to the caller to be copied to NewString.

All these copies make the process slow. In C you can do this:

StringPtr = "This Is A String"
ToLower(StringPtr)

StringPtr points to the string, ToLower() receives the pointer and performs the conversion on the original string without any copying taking place.

Function pointers allow C to be used in a more object orientated way; C doesn't support objects, but a structure can contain a collection of data and function pointers so the structure can effectively contain data and the functions needed to process it.

The danger of pointers is that they point directly into computer memory and its impossible for the compiler to be certain that you haven't made a pointer point outside of the program memory; the way you find out is when the program crashes when run with an exception error.

There is a also slight format error with the way pointers are described in C; for example consider the following function:

int Divide(int *a, int *b)
{
int r;
r = *a/*b;
return r;
}

Although it looks harmless, the compiler can't tell if the /*b; is introducing a comment or is part of the calculation and most compilers will produce a missing close comment message - although some will silently compile the program - but commenting out everything after the *a!

  1. Read more on C from : http://www.indiabix.com/c-programming/index.php
  2. Read more on C Pointer from :http://www.indiabix.com/c-programming/question-answer.php?topic=nqvqmuprt
User Avatar

Wiki User

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

Wiki User

15y ago

In 8086 programming (MS DOS), a far pointer is normalizedif its offset part is between 0 and 15 (0xF).

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is a pointer in C programming language?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is 'this pointer' in regards to computer programming?

It is a pointer which is pointing to present object with which the memberfunction is called in c++ language.


When was C - programming language - created?

C - programming language - was created in 1972.


What is the important of pointer in c programming?

It is accessing data by address.


What programming language is Android written in?

Android is programmed in the C and C++ programming language.


What do you mean by c language?

C is a programming language.


Name of object oriented programming language?

C++ is the name of a programming language.


Example of procedural programming language and object oriented programming language?

example of procedural programming are those programming language that have structure e.g basic,fortran,c++,c and pascal e.t.c


Who are the ancestors of C programming language?

programming languages B and BCPL which was used to derive C


Websites to download c C programming language books?

Download 1000s of C C C++ Programming Language. http://www.guruengineers.com


Why is programming language named C and not simply C?

I am guessing you typed the question wrong, the way I understand your question is "Why is the programming language named C++ and not C ? " The answer to this is that there is a programming language called C, and in that programming language the ++ means increment by one. So C++ is the language C improved, as such it can read and compile all C programs in addition to having other features that C does not have.


What is a programming language and with three example?

A programming language is a language in which a human can tell a machine to do something, three examples include: C, C++ and C#.


What programming language is PHP made with?

PHP is written in the C programming language.