Suppose I have a two-dimensional array consisting of 3 lines. I need to delete the 2nd line for example. How to do it?
char* GetLine(){ char* text = NULL; char ch; int counter; for(counter = 1 ;; counter++){ ch = getchar(); text = (char*)realloc(text,counter*sizeof(char)); if(ch != '\n'){ *(text+counter-1) = ch; } else{ *(text+counter-1) = '\0'; break; } } return text; } int main(void) { // Disable stdout buffering setvbuf(stdout, NULL, _IONBF, 0); char **lines = NULL; int i; lines = (char**)malloc(sizeof(char*)*3); for(i = 0; i < 3;i++){ *(lines+i) = GetLine(); } for(i = 0; i < 3; i++){ puts(*(lines+i)); } return 0; }