Record separation problem
Let us assume that a particular database program manages a simple mailing list which consists of one record for each person on the list, and a number of fields containing information about each person (their name, address, etc). The program can read in data produced by a word processor provided that data is structured in the following way
Each record to be read must be a single paragraph terminated by a return character, and each field within a record is separated by a tab character. For Example:
Colin Jameson|tab|33Falcon Street|tab|Waverly|tab|NSW|tab|2114|return|
Would be read as one record containing five fields. The end of the data is marked with the # (Hash) character which immediately follows the return ending the last paragraph.
Assuming that there is at least one line of valid data at the start of the input file, describe an algorithm that the program might use to read such data one character at a time and place the information into separate fields and records. The algorithm reports the number of records read when all records have been processed.