Go to Post It's never been about the robots. But the robots make an interesting misdirection that we all use. So its ALL about the robots. :rolleyes: - Foster [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Spotlight this post!  
Unread 28-01-2007, 13:38
buddy.smith buddy.smith is offline
Master Control
FRC #1795
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2007
Location: atlanta
Posts: 20
buddy.smith is an unknown quantity at this point
Re: Pointers/References?

Quote:
Originally Posted by htwiz2002 View Post
Code:
void Terminal_eepromreadset(unsigned char set, unsigned char *data1, unsigned char *data2, unsigned char *data3, unsigned char *data4)
{
Why not do this:
Code:
void Terminal_eepromreadset(unsigned char set, unsigned char data[4])
{
    //Consolidate this on verify that it works!!!
    unsigned int address = set * 4;
    data[0] = EEPROM_Read(address);
    data[1] = EEPROM_Read(address + 1);
    data[2] = EEPROM_Read(address + 2);
    data[3] = EEPROM_Read(address + 3);
}
Note that this is the same as:
Code:
void Terminal_eepromreadset(unsigned char set, unsigned char *data)
Quote:
Originally Posted by htwiz2002 View Post
Code:
// later on in another function this is how it's called:
unsigned char version1;
unsigned char version2;
unsigned char version3
unsigned char version4;
Terminal_eepromreadset(0, version1, version2, version3, version4); break;
version1 is a 'char'. Terminal_eepromreadset wants a char*. To convert a char to a char *, you use the addressof operator (&):
Code:
Terminal_eepromreadset(0, &version1,.....)
Alternately, you can use my suggestion:
Code:
unsigned char version[4];
Terminal_eepromreadset(0, version);
In C, an array and a pointer are mostly equivalent. version is a char*, version[N] is a char.

Confusing as dirt?

ttyl,

--buddy
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
pic: Robonauts' Magnum Shoots 3 Pointers with WNBA Comets Natchez Extra Discussion 8 28-10-2006 20:26
Pointers in EasyC P1h3r1e3d13 Programming 6 13-03-2006 00:02
Can't use pointers nor refrences. cibressus53 Programming 9 05-11-2004 15:44
Pointers to structs? Jeff McCune Programming 2 17-02-2004 13:17
Laser Pointers.. archiver 2001 18 24-06-2002 00:08


All times are GMT -5. The time now is 17:43.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi