Records need some help on adding, editing, deleting

I'm doing a program for my A-Level computing and it will have a few databases wgere the user can add, delete and edit new records. Each record will have a few variables i'm having trouble with it, at the moment i use this command for reading in new variables

a : array[1..30] of contact{record name}

f : file of contact


I know i need to change the one to an integer and store it somehow, need help quickly please

Don't know how to edit or delete either


  • Ok here I give you some pseudocode you can think about. But be sure to understand what you are doing if you decide to use this.

    If you are going to read in a number of elements into the array you can use a loop with an integer variable that increments with iteration(execution of the loops body)

    for i := 1 to number_of_elements_to_read do


    If you want to edit a specific element you can ask the user what element to edit and store that element number in a variable and do something like this


    If you don't know the number of the element but know some of

    the info in it you can do a search with a loop that uses an

    incrementing variable.

    ask user about the name of the person he wants to edit(or id, adress or what ever) then search through the entire array using a while or repeat until loop and then check each element you pass, and if the element is the one you want then exit the loop then you just use the variable to edit the element you want.

    deleting elements from an array is not a very easy task, not very hard either, but I would say the best thing to do would be to learn how to

    use and create a linked list instead of an array. If that is an unnacceptable solution here you must either just reset the element you want to delete (setting all names to '' and all integers to 0 and so on). Deleting for real would require use of an extra array where you first put all the elements you want top keep from the original list and then putting them back in the old list "over" the ones that allready are there.


    Hope it helped.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!