Skip to content

hi, i think there some issue on your strcopy. i hope this could help #1

@Abdi-29

Description

@Abdi-29
` char *copy(char *array){
int i, counter = 0;

counter = strlen(array);
char *arraycopy = (char*) malloc (sizeof(char) * counter + 1);   //the +1 is for the null terminator at the end
int j;
for(j = 0; j < counter; j++){      //it's better to use counter here as you already know the length of your array. you program might //segment fault if check the length of your copyarray
	arraycopy[j] = array[j];
}
   arraycopy[counter] = array[counter];     //you can use calloc if you don't want to write the null terminator manually
return arraycopy;

}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions