Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Newbie need help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ssikmace




PostPosted: Wed Mar 31, 2004 8:53 pm   Post subject: Newbie need help

Hello, im trying to define an array using words read from a file but i don't really know how, this is my best guess so far. Thx


var search : string
var streamin : int
var word : string
var itemcount : int

open : streamin, "Drawer.txt", get
assert streamin > 0
itemcount := 0

loop
get : streamin, skip
exit when eof (streamin)
get : streamin, word
itemcount := itemcount + 1
end loop

put itemcount
var items : array 1..itemcount of string
for i:1..itemcount
get streamin, items (i)
end for

for i:1..itemcount
put items(i)
end for
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Wed Mar 31, 2004 8:56 pm   Post subject: (No subject)

eh... well you're missing the colon in your 2nd get.

and you should close and reopen the file to start reading from the beginning again after you finished counting.

I'd tell you to just use a flexable array and have a single loop instead, but that might be a bit too advanced... Thinking
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
ssikmace




PostPosted: Wed Mar 31, 2004 8:57 pm   Post subject: (No subject)

lol thx its always something simple.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: