CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

strcpy and write_eeprom

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
iw2nzm



Joined: 23 Feb 2007
Posts: 55

View user's profile Send private message

strcpy and write_eeprom
PostPosted: Thu Oct 11, 2007 8:50 am     Reply with quote

Hi,

please consider this short code:

Code:

char   *sPassword[9];

void main() {
        int8 i;

...
   strcpy(sPassword, "0000");
   for (i = 0; i < 8; i++) write_eeprom(12 + i, sPassword[i]);
        for (;;) {}

}


After programmed with ICD2 and ran, I expect to see in the eeprom something like this:

0x0C -> 0x30 // '0'
0x0D -> 0x30 // '0'
0x0E -> 0x30 // '0'
0x0F -> 0x30 // '0'
0x10 -> 0x00 // '\0'
0x11 -> ???
0x12 -> ???
0x13 -> ???

Where ??? means not significative data.

Insted I read:

0x0C -> 0x30 // '0'
0x0D -> 0x30 // '0'
0x0E -> 0x00 // '0'
0x0F -> ???
0x10 -> ???
0x11 -> ???
0x12 -> ???
0x13 -> ???

Do you know why?

I'm using a PIC18F4520 and CCS PCH 4.025.

Marco / iw2nzm
Ttelmah
Guest







PostPosted: Thu Oct 11, 2007 9:02 am     Reply with quote

Your declaration of sPassword, says that this is a pointer to an array. An _array_ declaration, is already a pointer to the data. Get rid of the leading '*' on the declaration.

Best Wishes
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Thu Oct 11, 2007 9:20 am     Reply with quote

Actually isn't it an array of char pointers!
A pointer to an array would be

char array[10];
char *p = array;

Where as
char *p[10];
Is an array of 10 char pointers, ie
char array[10][10];
p[0] = array[0];
p[1] = array[1];

*p[0] = array[0][0];

etc...
iw2nzm



Joined: 23 Feb 2007
Posts: 55

View user's profile Send private message

PostPosted: Thu Oct 11, 2007 9:21 am     Reply with quote

Well, let me say I'm too tired to code today... It's better I stop and go out for a walk... Laughing

Thanks for the quick answer!
Marco / iw2nzm
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group