Help - pointer notation please... 
Author Message
 Help - pointer notation please...

Hi.

I've read my C book. I've gotten th C FAQ. I've read the file
"ptrtutor.txt" a tutorial on pointers. But I havn't seen explained the
following. Can you help?

Sometimes when prototyping a function the function name is pre-fixed
by an asterisk. Why? What does it mean?

Putting an asterisk before a variable name declares it as a pointer
variable. Putting one before the variable in use means you want to
access the data pointed to. Why is there sometimes an asterisk AFTER a
variable?

All hint's will be of GREAT use. Thanks.

---
Mic.
From very windy and now snowy Worthing; England.

(I just lost 4 fence panels to the wind here! The cost of
replacing them could have bought me a new windows compiler!)



Tue, 11 Aug 1998 03:00:00 GMT  
 Help - pointer notation please...

Quote:

>Hi.
>I've read my C book. I've gotten th C FAQ. I've read the file
>"ptrtutor.txt" a tutorial on pointers. But I havn't seen explained the
>following. Can you help?
>Sometimes when prototyping a function the function name is pre-fixed
>by an asterisk. Why? What does it mean?
>Putting an asterisk before a variable name declares it as a pointer
>variable. Putting one before the variable in use means you want to
>access the data pointed to. Why is there sometimes an asterisk AFTER a
>variable?

Putting the asterisk before the function name means the function
returns a pointer...as for the second question, don't know.  Never
seen what you describe...

Adam



Tue, 11 Aug 1998 03:00:00 GMT  
 Help - pointer notation please...

Quote:

>Sometimes when prototyping a function the function name is pre-fixed
>by an asterisk. Why? What does it mean?

Do you mean somethink like
 char *strcpy( );
?

Read it as
 char* strcpy();
which means that it returns a value which type ich char* which
means that it returns a pointer to char.

h.f.s.

--
Hans Friedrich Steffani
Institut fuer Elektrische Maschinen und Antriebe
TU Chemnitz-Zwickau



Tue, 11 Aug 1998 03:00:00 GMT  
 Help - pointer notation please...

Quote:

> Hi.

> I've read my C book. I've gotten th C FAQ. I've read the file
> "ptrtutor.txt" a tutorial on pointers. But I havn't seen explained the
> following. Can you help?

> Sometimes when prototyping a function the function name is pre-fixed
> by an asterisk. Why? What does it mean?

1) The function returns a pointer to soe type. Such as:

char *strcpy(char *s1, const char *s2); /*a function taking two pointers
                                         to char and and returning
                                        a pointer to char*/

Quote:

> Putting an asterisk before a variable name declares it as a pointer
> variable. Putting one before the variable in use means you want to
> access the data pointed to. Why is there sometimes an asterisk AFTER a
> variable?

Maybe it is the multiplication operator, which, coincidentally is '*', too.

Quote:

> All hint's will be of GREAT use. Thanks.

> ---
> Mic.
> From very windy and now snowy Worthing; England.

> (I just lost 4 fence panels to the wind here! The cost of
> replacing them could have bought me a new windows compiler!)

Hope this helps.

                                                Regards,

                                                        Emil



Wed, 12 Aug 1998 03:00:00 GMT  
 Help - pointer notation please...

Quote:
>Hi.

>I've read my C book. I've gotten th C FAQ. I've read the file
>"ptrtutor.txt" a tutorial on pointers. But I havn't seen explained the
>following. Can you help?

>Sometimes when prototyping a function the function name is pre-fixed
>by an asterisk. Why? What does it mean?

>Putting an asterisk before a variable name declares it as a pointer
>variable. Putting one before the variable in use means you want to
>access the data pointed to. Why is there sometimes an asterisk AFTER a
>variable?

>All hint's will be of GREAT use. Thanks.

>---
>Mic.
>From very windy and now snowy Worthing; England.

>(I just lost 4 fence panels to the wind here! The cost of
>replacing them could have bought me a new windows compiler!)

The use of '*' is context dependent.  In variable declarations it always
means pointer (unless it is used in an initializer).  In statements it can
either mean "dereference pointer" or "multiply" depending on how it is used.

Consider:

int ad = 3 * 4, *a, bd, *b, c;

int main()
{
    b = &bd;
    a = &ad;
    *b = 10;
    c = *a * (*b);
    return(c);

Quote:
}

Can you see why c == 120 is true?




Fri, 14 Aug 1998 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Please Please Help! - pointer notation

2. subscript notation with pointer to pointer fails

3. Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!

4. Please help!!!!Please help!!!!Please help!!!!

5. Dereference void pointer help, xxgdb help please

6. Pointer notation

7. Validity of simplified notation for calling functions from function pointers

8. Pointer Notation Flaw

9. Pointer to struct function NEWBIE PLEASE HELP

10. pointer probelm, please help

11. Fundamental pointer misunderstanding -- please help

12. Please help~~Array and Pointer

 

 
Powered by phpBB® Forum Software