

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


void quit( void ) { FILE *fp; NODE *ptr = top; fp = fopen( file_name, "w" ); for ( ptr = ptr - > link; ptr != NULL; ptr = ptr - > link ) fprintf( fp, "%s", ptr - > line ); exit( EXIT_SUCCESS ); }
void delet( const char s ) { / printf( "Entered delet\n" ); / int count; char err_msg[] = "** Error. Command is: "; if(sscanf( s, "%d", &count)!=1) printf("%s d x\n", err_msg); else { NODE ptr = current->link; int delete_count = count; while (count > 0 && ptr != NULL) { printf("%s", ptr->line); current->link = ptr->link; / delete the line */ ptr->link = avail; avail = ptr; ptr = current->link; --count; } if (count < delete_count) printf("\ndeleted %d lines\n", delete_count-count); else printf("\nnothing deleted\n"); } }
if (bottom == ptr) bottom == current;
typedef struct node { char line[ MAX_LENGTH ]; /* text of line */ struct node link; / pointer to next line */ } NODE;