#include #include #include #include typedef int *LIST_PTR; void fget_list(LIST_PTR *list, int *count); int linear_search(LIST_PTR list, int count, int target); void remove_int(LIST_PTR list, int count, int loc); int menu(void); void pause(void); main() { int choice; int count,i,pos,target; LIST_PTR list; do { choice = menu(); switch(choice) { case 1 : clrscr(); /* add an integer in the file */ printf("To be implemented by YOU!"); pause(); break; case 2 : clrscr(); /* deletes an integer from the file */ free(list); fget_list(&list,&count); printf("Enter the number you wish to remove: "); scanf("%d",&target); pos=linear_search(list,count,target); if (pos != -1) remove_int(list,count,pos); else printf("Sorry, no such number exists!"); pause(); break; case 3 : clrscr(); /* display all numbers in the file in step of 15*/ free(list); fget_list(&list,&count); for (i=0; i 5); return choice; } /* reads all the integers in the file integer.dat into a dynamic array */ void fget_list(LIST_PTR *list, int *count) { FILE *inp; int n; LIST_PTR p; int cnt=0,i; inp=fopen("c:integers.dat","r"); while (!feof(inp)) { fscanf(inp,"%d",&n); cnt++; } rewind(inp); p=(LIST_PTR)malloc(cnt*sizeof(int)); for (i=0; i