www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/17/16:45:26

From: Martin Ambuhl <mambuhl AT earthlink DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Question about pass by pointer
Date: Thu, 17 Sep 1998 16:20:00 -0400
Organization: Nocturnal Aviation
Lines: 30
Message-ID: <36016EF0.D08D173D@earthlink.net>
References: <3600c4ec DOT 1308545 AT news DOT hknet DOT com>
NNTP-Posting-Host: 1cust129.tnt12.nyc3.da.uu.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

¤ý¤ô wrote:
> 
>         void change(char *n){
>             *n=70;
>         }
>         int main(){
>             char Number=0;
>             printf("Number=%i\n",Number);
>             change(&Number);
>            printf("Number=%i\n",Number);
>            return 0;
> 
> What I want to ask is that when the address of Number pass to function
> "change", the address value will store in var 'n' , but not '*n' ?!
> 
> Damn, I don't know how to say it....... :(

Yes, you have it right. 'n' in change() contains &Number (the address of
Number), so the line
	*n = 70;
has the effect of
	*(&Number) = 70;
or
	*&Number = 70;
or
	Number = 70;

-- 
Martin Ambuhl (mambuhl AT earthlink DOT net)
Note: mambuhl AT tiac DOT net will soon be inactive

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019