hi,
say I have an array of strings consisting of names..now if I want to delete one of the names & move the list up how would I do that..basically..how would I overwrite that name?
A :confused:
Printable View
hi,
say I have an array of strings consisting of names..now if I want to delete one of the names & move the list up how would I do that..basically..how would I overwrite that name?
A :confused:
basically the answer is to swap the array around. You know, from your deleted string in the array go up the elements swapping them
Code:for(i = whatever element your string to delete is; i < elements in the array - 1; i++)
for(j = whatever element your string to delete is + 1; j < elements in the array; j++) {
strcpy(temp,string[i]);
strcpy(string[i], string[j]);
strcpy(string[j], temp);
}
/* your string to delete is now at the last element */
/* so delete it by copying a null */
strcpy(string[i], "\0");