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

Username:   Password: 
 RegisterRegister   
 Help with file input/output
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
recneps




PostPosted: Sat Feb 07, 2004 11:59 am   Post subject: Help with file input/output

Ok, heres my problem. I'm doing a test to see how the input/output to a file works, and i can output 2 variables, but i cant get 2 variables. Should i be able to ? If so, why isnt it working, it says "attempt to read past eof"

heres my code:
code:
var filenum, filename, iocapacity, streamin, streamout : int
var test : string
var price : real
price := 29.99
test := "item"
open : streamout, "test.txt", put
put : streamout, test, price

close : streamout

open : streamin, "test.txt", get
get : streamin, test, price

close : streamin
put test, price
Sponsor
Sponsor
Sponsor
sponsor
AsianSensation




PostPosted: Sat Feb 07, 2004 12:16 pm   Post subject: (No subject)

when you are doing this:
code:
put : streamout, test, price
you have outputted the information on 1 line, so when you tried to get it, test now becomes "item29.99" and there isn't any info for you to get on the next line, so that gives you an error.

code:
put : streamout, test, '/n', price
doing this will output an endline character, and it skips a line in the textfile.

edit: or, as dodge suggested, you can use skip instead of '/n'.
Andy




PostPosted: Sat Feb 07, 2004 12:30 pm   Post subject: (No subject)

azn, who uses \n in turing? just do skip
recneps




PostPosted: Sat Feb 07, 2004 6:45 pm   Post subject: (No subject)

Thanks guys, I'm gonna try make a cash register for my mom Smile So i can make a receipt with item name and price , etc Smile
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  [ 4 Posts ]
Jump to:   


Style:  
Search: