Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » C

pointer question

 
Jump to:  
 
mdh
PostPosted: Sun Jun 29, 2008 12:03 am    Post subject: pointer question
       
In one of K&R's exercises, I was caught out by my doing this.

If p is a pointer of type double, then

*--p was what I wanted, not --*p.

I know that the former returns a double one position before what p is
currently pointing to, but what does --*p do? ( I think it is
multiplying something, but not sure.)

Thanks
 

 
pete
PostPosted: Sun Jun 29, 2008 12:03 am    Post subject: Re: pointer question
       
mdh wrote:
Quote:
In one of K&R's exercises, I was caught out by my doing this.

If p is a pointer of type double, then

*--p was what I wanted, not --*p.

I know that the former returns a double one position before what p is
currently pointing to, but what does --*p do? ( I think it is
multiplying something, but not sure.)

--*p decrements the double that p points to.

Multiplication isn't defined for pointer operands.

--
pete
 

 
mdh
PostPosted: Sun Jun 29, 2008 12:20 am    Post subject: Re: pointer question
       
On Jun 28, 5:17 pm, pete <pfil...@mindspring.com> wrote:
Quote:
mdh wrote:
In one of K&R's exercises, I was caught  out by my doing this.

If p is  a pointer of type double, then

*--p was what I wanted, not --*p.

I know that the former returns a double one position before what p is
currently pointing to, but what does --*p do? ( I think it is
multiplying something, but not sure.)

--*p decrements the double that p points to.

Multiplication isn't defined for pointer operands.

--
pete

I should have known that!! Thank you.
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

Ziaja dessous Szyby samochodowe Stwarzanie świata - Miłosz Czesław albergo a venezia