problem with pointers and arrays

Hi,

I have this

typedef struct prog_list_tag {

  u16 index;

  u16 bank_number;

  char file_name[4];

  char bank_name[16];

} prog_bank_list_t;


// each entry represents one available PROG bank on SD card

prog_bank_list_t prog_bank_list[100];

and this:

extern char current_prog_bank_name[16];

How can I copy the bank_name in the struct (e.g. the one in the second entry of prog_bank_list) into the array current_prog_bank_name?

I think I got a mental block right now…

#include <string.h>

...

int bank = 0;
memcpy((char *)current_prog_bank_name, (char *)prog_bank_list[bank].bank_name, 16);
[/code]









Best Regards, Thorsten.

I definitely had a mental block! Thanks!!

I also want to “memcpy”

C, 8Bit Core, 18F4685:

 

 

 #include <string.h>

int MtxLoad0[8]; //Destination Array
int Mtx0Part0[8]; //Source Array

if(pin == 0 && pin_value == 0){memcpy(MtxLoad0, Mtx0Part0, 8);}

give me this error:

 

error: missing definition for symbol “_memcpy”, required by “_output/main.o”

 

where do i have to define “memcpy”?

memcpy() isn’t available, copy it with a for loop…

 

Best Regards, Thorsten.

ok thankz i made this:

 

#include <string.h> 
int MtxLoad0[8]; //Destination Array 
int Mtx0Part0[8]; //Source Array 
int LoroCount; //counter 4 "for" loop -LoadRoll...

if(pin == 0 && pin_value == 0)
{for(LoRoCount=0; LoRoCount<8; LoRoCount++) {MtxLoad0[LoRoCount]=Mtx0Part0[LoRoCount];}}