answersLogoWhite

0

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

9y ago

What else can I help you with?

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.


Name of object oriented programming language?

C++ is the name of a programming language.


What do you mean by c language?

C is 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.


Why does is used as a pointers in c language?

Let's suppose, you wanted to ask:Why thisis used as a pointer in C++ language? Because it is a pointer to the 'current object'.


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 IS POINTER TO POINTER IN C POINTER?

Pointer in C is Memory Reference. It stores memory address of any variable, constant, function or something you later use in your programming. Pointer basically used to ease the referencing of variables and others or in polymorphism and inheritance.


Which programming language uses a mouse pointer shaped in the form of turtle?

Logo


What programming language is PHP made with?

PHP is written in the C programming language.


What is the C language used for?

Programming.


Why pointer is callded jewel of c language?

a pointer is a derived data type in c. pointers are undoubtedly one of the most distinct and exciting features of c language.it has added power and flexibility to the language. *pointers are more efficient in handling arrays and tables. *pointer can be used to support dynamic memory management. *pointers reduce length and complexity of programs. *increase the execution speed and thus reduce the program execution time. by following character's real power of c lies in proper use of pointers. pointer is called the jewel of c-language.


Why you need C programming?

C- Programing is basically a programing language of a computer. It helps to create software programing language which is usefull in creating softwares & data base programes. C programing language is the first & basic programing language. Other programing languages are:- C, C++ & C# (latest).


What programming language is similar to C?

c++


What are the Examples of portable programming language?

Many programming languages allow programs to be portable from one kind of computer to another, including* the C programming language* Pascal* Forth* C++* Java* Pythonand many others. Yes, the C programming language was designed to encourage machine-independent programming.The C programming language is portable to more CPUs than any other programming language.