Searching \ for '[PIC]: Tied up with String -- Language Lawyer Stri' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/languages.htm?key=language
Search entire site for: 'Tied up with String -- Language Lawyer Stri'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Tied up with String -- Language Lawyer Stri'
2001\07\21@163144 by Bob Ammerman

picon face
Ok,

I've put on my language lawyer hat because I really have to clear up a
misconception that is dogging this thread:

NOTE: An array name is _not_ a pointer in C.

An array name is an identifier for an area of memory (the array).

It is just that in _most_ contexts you can treat the array name as a pointer
to the first element of the array. The terminology typically used is that it
'decays' to the pointer.

There are at least two places where treating the array name as a pointer
breaks down:

1) You cannot change this 'pointer' to point to anything else, ever.
For example, given:

char buf[20];
char buf2[10];

buf = buf2; // This is illegal. You are trying to change the array name buf
to point to something else (in this case to be equal to the pointer to which
'buf2' decays).


2) When using the array name in a sizeof operation, you get the size of the
entire array, _not_ the size of a pointer to the elements. Thus, given:

char buf[20];

sizeof(buf) will be 20.

2) [Optional for advanced language-law students] There is actually an
exception to the rules described in 1 and 2, above. When an array is
declared as argument to a function:

void foo(char buf[20])
{
}

Then within the function 'foo', buf really _is_ treated as a pointer to
char. You can freely adjust it or assign things to it:

   char buf2[20];
   ++buf;
   buf = buf2;

And sizeof(buf) will return the size of the pointer, not the buffer!

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\07\21@195831 by Hans W

flavicon
face
Point taken, si I made a simple mistake it should have been
"an array name parameter is a pointer"  K&R page 99



Bob Ammerman wrote:

{Quote hidden}

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\07\23@122514 by Lawrence Lile

flavicon
face
part 1 493 bytes content-type:text/plain; (decoded base64)

Bob Rammerman has made me write 1000 times on the blackboard that I must turn caps sensitivity back on in my C compiler, and start to pay attention to caps, style, etc.  So as pennence for my crimes, I have posted the attached document on my bulletin board at my desk.  As it's mostly meant for my own edification, it probably misses some points others would make.  Probably good for a laugh, anyway.


c lAnguAGE cApS CriMinAL,

laWReNCE LILe



part 2 23077 bytes content-type:application/msword; (decode)

part 3 131 bytes
--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\07\23@123533 by Spehro Pefhany

picon face
At 11:24 AM 7/23/01 -0500, you wrote:
>Bob Rammerman has made me write 1000 times on the blackboard that I must
turn caps sensitivity back on in my C compiler, and start to pay attention
to caps, style, etc.  So as pennence for my crimes, I have posted the
attached document on my bulletin board at my desk.  As it's mostly meant
for my own edification, it probably misses some points others would make.
Probably good for a laugh, anyway.

"Obfusticates"?   Also check out the usenet group:
alt.possessive.its.has.no.apostrophe ;-)

Best regards,

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Spehro Pefhany --"it's the network..."            "The Journey is the reward"
spam_OUTspeffTakeThisOuTspaminterlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com
Contributions invited->The AVR-gcc FAQ is at: http://www.bluecollarlinux.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\07\23@171324 by Brent Brown

picon face
Thanks Lawrence, well written - and useful too.
Obfusticates => obfuscates (well at least then the spelling checker
says it is OK)

Brent Brown
Electronic Design Solutions
16 English Street
Hamilton, New Zealand
Ph/fax: +64 7 849 0069
Mobile/text: 025 334 069
eMail:  .....brent.brownKILLspamspam@spam@clear.net.nz

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...