Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: What does the asteriks mean?

Thread Tools

Re: What does the asteriks mean?
Posts: n/a
The asterik before any variable declaration in program means a pointer

For eg.

int index; /* this is simple variable , which will hold a value */


int * pIndex; /* this is a pointer variable. */

Pointer variables do not hold normal values. Instead they point to
other variable. This means it should contain the address of that

With pointers, there are two frequently used operators.

1. the asterik operator (*). This is called as De referencing
operator. It dereferences the value pointed to by the pointer.

2. the address operator (&). This is used to make pointer point to
some variable of same type.

For eg;

/* These are simple variables */

int intVar = 10; /* integer variable */
float floatVar = 10.45; /* float variable */
char charVar = 'A'; /* char variable */

/* the following are pointers to above variables */

int * intPtr = &intVar; /* intPtr now points to intVar */
float * floatPtr = &floatVar; /* floatPtr now points to floatVar */
char * charPtr = &charVar; /* charPtr now points to charVar */

/* Print all values */

printf ("Integer variable = %d\tthrough pointer = %d\n", intVar,
printf ("Float variable = %f\tthrough pointer = %f\n", floatVar,
printf ("Character variable = %c\tthrough pointer = %c\n", charVar,

Moe on Pointers...refer K&R and Y P Kanetkar books on Pointers in C...

Sumit Removed) wrote in message news:<(E-Mail Removed)>. ..
> What does the * mean before the p in the following code? I figure
> that it has something to do with pointers, but I haven't learned about
> pointers yet.
> ========
> #include <stdio.h>
> #include <string.h>
> char answer[100], *p;
> printf("Type something:\n");
> fgets(answer, sizeof answer, stdin);
> if((p = strchr(answer, '\n')) != NULL)
> *p = '\0';
> printf("You typed \"%s\"\n", answer);
> ========
> The code is from the C FAQ located at the following URL:

Reply With Quote
Keith Thompson
Posts: n/a
Just for the record, it's spelled (and pronounced) "asterisk".

Keith Thompson (The_Other_Keith) (E-Mail Removed) <>
San Diego Supercomputer Center <*> <>
Schroedinger does Shakespeare: "To be *and* not to be"
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
The modem for Asteriks Antonio VOIP 4 05-20-2004 05:46 PM
Asteriks! What i need? Antonio VOIP 2 05-14-2004 06:47 AM
Re: What does the asteriks mean? C Programming 5 06-26-2003 10:13 PM
Re: What does the asteriks mean? Dan Pop C Programming 0 06-26-2003 12:57 PM
Re: What does the asteriks mean? Tom St Denis C Programming 1 06-26-2003 01:43 AM