Guest Guest
|
Can I use Pointers in an Array? |
Posted: Tue Jul 25, 2006 9:20 pm |
|
|
Hello, I'm trying to write 14 bytes to EEProm. The first function works correctly however I'm trying to reduce the code. I attempted a for loop with pointers in the second function. I don't have any experience wth pointers so I'm assuming I can't have an array of pointers. Can anyone suggest a way to do what I'm trying to do?
Code: |
void WriteEEprom(){
write_eeprom(5,MAKE8(Fqmax,0));
write_eeprom(4,MAKE8(Fqmax,1));
write_eeprom(9,MAKE8(Vmax,0));
write_eeprom(8,MAKE8(Vmax,1));
write_eeprom(13,MAKE8(Imax,0));
write_eeprom(12,MAKE8(Imax,1));
write_eeprom(17,MAKE8(kWmax,0));
write_eeprom(16,MAKE8(kWmax,1));
write_eeprom(15,MAKE8(kWmax,2));
write_eeprom(14,MAKE8(kWmax,3));
write_eeprom(25,MAKE8(HourMeter,0));
write_eeprom(24,MAKE8(HourMeter,1));
write_eeprom(23,MAKE8(HourMeter,2));
write_eeprom(22,MAKE8(HourMeter,3));
}
|
Code: |
void WriteEEprom(){
int wEEaddr[14] = {5,4,9,8,13,12,17,16,15,14,25,24,23,22};
int *wEEval[14] = {&Fqmax,&Fqmax+1,&Vmax,&Vmax+1,&Imax,&Imax+1,&kWmax,&kWmax+1,&kWmax+2,&kWmax+3,&HourMeter,&HourMeter+1,&HourMeter+2,&HourMeter+3};
int i;
for(i=0;i>14;i++){
write_eeprom(wEEaddr[i],*wEEval[i]);
}
}
|
|
|