delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/03/17:16:21

From: Isaac Waldron <waldroni AT lr DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Addresses of arrays
Date: Tue, 03 Mar 1998 16:51:32 -0500
Organization: The Computer Nerd
Lines: 25
Message-ID: <34FC7B64.2265DCAD@lr.net>
References: <Chameleon DOT 980301230048 DOT nrotem AT netvision DOT netvision>
Reply-To: waldroni AT lr DOT net
NNTP-Posting-Host: plym2-1.worldpath.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Noam Rotem wrote:

> I try and try and try, and can't understand how come the address of an array is the same
> as the address of the first cell of it.
>
> int Arr[SIZE];
> if (Arr==&Arr) printf("Well, I give up...");
>
> I always thought the name of an array to act as a pointer to the first value. Am I wrong
> somehow?
>
> Does this mean I can use scanf("%s",&Str)?

 (signature clipped)
If my thinking is correct, then the following snippet should explain your problem:
int array[SIZE];
*array = 1; //*array points to the first data element in the array
array = 1; //this is not allowed, because you are trying to change the address of the first
element of the array.
//end code
--
Isaac Waldron <waldroni AT lr DOT net>
http://www.geocities.com/SiliconValley/Lakes/3574/index.html


- Raw text -


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