Split from: [TUT] [C] Using the EEPROM memory in AVR-GCC

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi

in this line

void eeprom_write_byte (uint8_t *__p, uint8_t __value);

__p is a pointer but we have to use "&" in below line

bh=eeprom_read_word(&_ee_h[_t_ee]);

"&" means content of _ee_h[_t_ee] not the address of it 

can anyone tell me why we use "&" instead of * ?

thanks a lot

 

 

 

Last Edited: Thu. Sep 14, 2017 - 01:49 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

That's a basic question about C - nothing to do with EEPROM.

 

The fact is that a pointer holds the address of a variable. You use &, the "address of" operator to get the address of a variable that can then be assigned to a pointer. You read/write the contents of the address held in the pointer using * (the pointer dereference operator)

 

If you don't have a good book about learning C you should consider buying a copy of Kerninghan & Ritchie which is the seminal work about C.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ahmadasadi wrote:
"&" means content of _ee_h[_t_ee] not the address of it

NO: you have that completely the wrong way around!

 

'&' is the "address-of" operator in 'C'.

 

You aren't confusing it with specifying a Reference parameter in C++, are you?

 

In 'C',  &_ee_h[_t_ee] gives you the address of _ee_h[_t_ee]

 

can anyone tell me why we use "&" instead of * 

As clawson said, any decent 'C' textbook will tell you that.

 

Here are some 'C' learning & reference materials for you: http://blog.antronics.co.uk/2011...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
You aren't confusing it with specifying a Reference parameter in C++, are you?

B-b-but... It has nothing to do with "content of" in C++ either!

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

C++ has meaningful content?!?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

We can have a serious discussion about that, Lee. Or you can put a smilie in there to make it clear you where joking. Please select one. )-:<

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JohanEkdahl wrote:
We can have a serious discussion about that, Lee. Or you can put a smilie in there to make it clear you where joking. Please select one. )-:<
If a joke needs a smiley, one should suspect that the joke is not funny.

International Theophysical Year seems to have been forgotten..
Anyone remember the song Jukebox Band?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Smilies are not, IMO, used because "a joke needs it". They are used so that the joke is not mis-interpreted ass serious, angry or some other  state of mind not being "joking". It's not that "without the smilie the joke isn't funny". It's "with the smilie it can not  be taken for anything but a joke".

 

Human communication is complicated. Especially when the medium is text. A joke that is spotted immediately if spoken/heard, because of tone of voice, possibly body-language etc, can easily be interpreted as a serious statement in text.

 

Now, I'm leaning towards Lee was joking. But 1) I sort of know him (since we both have been here for 15 odd years, and 2) I am fairly confident with my English (written, spoken and "cultural").

 

The problem arises when someone that does not know Lee, and is less confident/versed in English comes along here and reads Lees comment.

 

Written communication loosing a lot of "content" v/s spoken/heard communication, at least for some types of messages, was identified more than 40 years ago. I suspect it was far earlier than that, but we used the simple text-based smilies at uni circa 1980.

 

Anyway, knowing Lee as good as I actually do he's just ignorant and don't know what he is talking about. He wouldn't spot meaningful-ness if it was on a 6 by 12 foot poster right in front of him.

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Thu. Sep 14, 2017 - 06:55 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JohanEkdahl wrote:
We can have a serious discussion about that, Lee. Or you can put a smilie in there to make it clear you where joking. Please select one. )-:<
Well, I can speak from personal experience that inheritance is indeed valuable.  The downside of that is the loss that triggered the inheritance.

 

Encapsulation always makes me shudder.  Check the Google images for "encapsulated cycst" for the source of such revulsion.

 

I know that nowadays one needs to have tolerance for those of a different "persuasion".  Some of us older folks that have lived sheltered lives just haven't been in much (if any) contact with many of the identified polymorphic groups.  So I'll just abstain on that one.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

JohanEkdahl wrote:
2) I am fairly confident with my English (written, spoken and "cultural").

Oh, yes, yours is probably gooder than mine.  Often you can construct English puns worse than my terrible attempts.

 

JohanEkdahl wrote:
Anyway, knowing Lee as good as I actually do he's just ignorant and don't know what he is talking about. He wouldn't spot meaningful-ness if it was on a 6 by 12 foot poster right in front of him.

Must not be a joke; no smilie.

 

It would indeed be more terrifying to make flippant responses to a poster if he were right in front of me, especially if that size.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.