2d array to 1d array conversion

Hi everybody

I'm trying to pass the information of a 2d array to a 1d array like this

char listbuffer[81];

char list1[81];
char list2[81];
char list3[81];
char list4[81];
char list5[81];

char* liste[5];

void Setupparty()
{
  liste[0] = list1;
  liste[1] = list2;
  liste[2] = list3;
  liste[3] = list4;
  liste[4] = list5;
}

void loop()
{
  liste[0] = SerialtoChararray(); // madeup function
  listbuffer = liste[x];
}

Everything works fine except that conversion from 2d to 1d array.

Has anybody got an idea on this?

I'm trying to pass the information of a 2d array to a 1d array like this

Which 2D array are you trying to pass to a 1D array?

You have a several arrays of characters and an array of pointers. All the arrays are 1D.

  listbuffer = liste[x];

listbuffer is an array. You can't assign a pointer to an array. There is a strcpy() function to copy NULL terminated arrays of chars from one array to another.

Make sure that your made up function ACTUALLY returns a pointer that points to valid data AFTER THE FUNCTION ENDS.

How about an approach like this?

struct List{
char list[81];
} liste[5];

Then you would refer to them as:

liste[i].list // where i is the desired index

A look at this Tutorial would help a great deal.

http://pw1.netcom.com/~tjensen/ptr/pointers.htm

You (of course) can have an array of pointers, an illfe vector search for then in this "Expert C Programming: Deep C Secrets" google book. And now a very long link

Mark

Hey everybody
i tried the strcpy() function and everything is working correctly now.

Thanks for your help

edit: thanks holmes4 for that tutorial.