1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Rep Power

    Populaton arraylist with pointers

    I am trying to populate an arraylist using pointer using the attached code; For some reason I am not able to move the values to **list->array; not sure what I am doing wrong;

    char *put(ArrayList *list, char *str) {

    int s= list -> size;
    char *temp_name [s+1];
    int index = 0;

    if (s>0) {

    for (index=0;index < s; index++) {
    temp_name[index] = *list->array[index];
    printf("List has %s \n", temp_name[index]);

    list->array[s] =temp_name;

  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Rep Power
    Please edit your post and put [code][/code] tags around your code.
    Copy again from your code editor so indentation is preserved.

    > temp_name[index] = *list->array[index];
    You might need to write
    temp_name[index] = (*list)->array[index];
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper

IMN logo majestic logo threadwatch logo seochat tools logo