Computer Science Canada record-write |
Author: | Thuged_Out_G [ Wed Dec 03, 2003 11:33 am ] | ||
Post subject: | record-write | ||
i have to make a program that will resemble something a school would use...i have to use records to store the persons name, phone #, street, and street number. all this is easy, but i need to write all the above info to a file, this i dont know how to do... also have to be able to delete, and search the record for a name, and display all inf for that name. heres what i got so far
|
Author: | McKenzie [ Wed Dec 03, 2003 2:43 pm ] | ||||||
Post subject: | |||||||
As most languages you can use the file in Text or Binary Mode. Text Easy to read and write in text editor (like Turing IDE). Can treat the file like it is the kb or screen (input or output) Binary Can read and write large data structures in one line. I suggest using binary for your problem. 1. Open file for binary write
2. Write the whole array in one line.
3. Close your file
When you want to retrieve the info, open the file for read, rather than write, and use read rather than write. |
Author: | Chimaera [ Wed Dec 03, 2003 2:54 pm ] |
Post subject: | |
you'll have to use a bubble sort and save the information to a second array |
Author: | Thuged_Out_G [ Wed Dec 03, 2003 4:49 pm ] | ||
Post subject: | |||
ok, ive got the writing to a file solved, i decided to go with "put" but i still dont know how to delete records from the array, or how to search it and i dont know what a "bubble sort" is either :S here is an update of my code
|
Author: | AsianSensation [ Wed Dec 03, 2003 11:26 pm ] |
Post subject: | |
if you want to delete something from an array, just shift every single element of the array after it one space up. ex. an array containing integers 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 let's say you want to delete 4 from the array, then just shift everything after 4 one space up. so the array becomes: 1, 2, 3, 5, 6, 7, 8, 9, 10, blank. You can empty out the last element if you want, so you can add other stuffs later on. |
Author: | Azzy [ Thu Dec 04, 2003 8:10 am ] |
Post subject: | |
theres two problems with the code.for the get name you can only input your first name or the program will crash.you can solve that by putting a :* at the end of get name. second of all.the program also crashes at the phone number if you input your area code.you should either fix it or if you can't just tell the user not to put it in. |