hi,
i have a struct:
when i create linked list element i do this:
what is the proper way to set the char*? is it:
please assume temp and length have been initialised properly.
TIA, rotis23
i have a struct:
Code:
struct list_el
{
char *sitename;
struct list_el * next;
};
typedef struct list_el site;
when i create linked list element i do this:
Code:
current_site = (site *)malloc(sizeof(site));
what is the proper way to set the char*? is it:
Code:
current_site->sitename = malloc(length * sizeof(char));
memset(current_site->sitename,'\0',length);
strcpy(current_site->sitename,temp);
please assume temp and length have been initialised properly.
TIA, rotis23