Computer Science Canada Records, arrays and redirection .. all in one huge mess! |
Author: | Vlax [ Thu May 25, 2006 9:20 pm ] | ||||
Post subject: | Records, arrays and redirection .. all in one huge mess! | ||||
Well, basically Im trying to read a little phonebook i made in note pad ... the problem is i cant use my record in my array and read the three variables..(or atleast i dont know how). I've followed instructions .. and nothing really helped except for some stuff on records .. here is what I have so far:
Im aware that this portion doesnt work: Quote:
can someone help me debug it so i can use Entry(i) and store 3 elements(fName, lName, number) into it? Thanks. |
Author: | TheOneTrueGod [ Thu May 25, 2006 9:32 pm ] | ||
Post subject: | |||
well, your main problem is that you don't have an array of entries, you have an array of the variables that the type "Entry" contains (If that made any sense to you. ) Basically, the type "Entry" is a custom variable declaration, much like "boolean" The correct syntax would be:
the reason being is phonebook is your variable type, and you have it declared as an array, therefore, you need to access element (i) of phonebook. Phonebook has more than one field, those being fName, lName, etc. so you need to tell turing which field you want to access. Read the tutorial on this stuff in the Tutorials section! |
Author: | Vlax [ Thu May 25, 2006 9:34 pm ] |
Post subject: | |
you may have just given me the knowledge to finish this ISU ... Thanks! |
Author: | TheOneTrueGod [ Thu May 25, 2006 9:39 pm ] |
Post subject: | |
No problem, 'swhat i'm here for. Thank you for using code tags and posting in the right section. (I assume that means you read the rules before posting. You're probably the first of your kind ) |
Author: | Vlax [ Mon May 29, 2006 11:34 am ] | ||
Post subject: | |||
Heres the finished product, but u need a data file...
|
Author: | wtd [ Mon May 29, 2006 12:32 pm ] | ||||
Post subject: | |||||
Functions are your friends. Imagine:
As:
Oh, and I would strongly advise you not to use magic numbers (15) in your code (if Turing allows you to get around this). Instead use constants. That way, if you wish to change the size of the array, you need only change one constant, rather than making changes throughout your code. |