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

constant arrays of strings

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



Joined: 04 Aug 2008
Posts: 4
Location: ISEL,Lisbon, Portugal

View user's profile Send private message

constant arrays of strings
PostPosted: Mon Aug 04, 2008 11:03 pm     Reply with quote

hi, i'm trying to get this to work in v4.057:
Code:
const char source[4][25]=      {"Note                    "
               ,"Velocity                "
               ,"Aftertouch              "
               ,"Control Change          "
               };
char bufferStr2[25];


pnt=source[currentPos]; //currentPos is a char type variable
memmove(bufferStr2,pnt,25);   



and all i get in bufferStr2 is nothing good: just random "trash" from the PICs memory banks.

This actually works if i remove the const from the array.

i've also tried to follow the second example from this page but i get the same errors :http://www.ccsinfo.com/content.php?page=flexconst. and i also tried every hint i could find in this forum.

Could anyone give me a hand.

Thanks

Diogo
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 05, 2008 12:57 am     Reply with quote

The program shown below has the following output:
Quote:

Note
Velocity
Aftertouch
Control Change


Code:
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

const char source[4][25]= {
"Note                    ",
"Velocity                ",
"Aftertouch              ",
"Control Change          "
};

//=========================
void main()
{
char *ptr;
char bufferStr2[25];
int8 i;

for(i = 0; i < 4; i++)
   {
    strcpy(bufferStr2, source[i]);   
    printf("%s \n\r", bufferStr2);
   }

while (1);
}
Diogo Melo



Joined: 04 Aug 2008
Posts: 4
Location: ISEL,Lisbon, Portugal

View user's profile Send private message

PostPosted: Tue Aug 05, 2008 2:19 pm     Reply with quote

PCM programmer wrote:
The program shown below has the following output:
Quote:

Note
Velocity
Aftertouch
Control Change


Code:
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

const char source[4][25]= {
"Note                    ",
"Velocity                ",
"Aftertouch              ",
"Control Change          "
};

//=========================
void main()
{
char *ptr;
char bufferStr2[25];
int8 i;

for(i = 0; i < 4; i++)
   {
    strcpy(bufferStr2, source[i]);   
    printf("%s \n\r", bufferStr2);
   }

while (1);
}


thanks! apparently i shouldn't have been using the memmove() function. I started using it when i had some troubles with strcpy() when i was using an older version of the compiler.

an unrelated thing: do you know if the compiler has somekind of problem with an array of structures? i keep getting an error in the mplab watch window: Unsupported Struct. do you know anything about it?

thanks again.

diogo
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Aug 05, 2008 5:35 pm     Reply with quote

The release note for 4.076 says:
Quote:
4.076 The COFF file format has been modified to allow MPLAB to read complex structures
This indicates the object file in earlier versions had some limitations...
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