I'm making a program for class that is supposed to write one word at a time to a text file and append it to whatever is there. It writes the file with no delimiters or new lines or capitalization. So if you entered "apple" and then entered "orange" and then "banana" the file will read "appleorangebanana". The program also has a read button that is supposed to read one word at a time and put it in a text field. How do you make the program figure out where apple ends and orange begins? I'm also not allowed to write a separate index file. This seems impossible to me but supposedly people have figured this out before.
4 Replies - 118 Views - Last Post: 15 November 2012 - 11:56 AM
#1
Im trying to read records one at a time from a file without delimiters
Posted 15 November 2012 - 10:53 AM
Replies To: Im trying to read records one at a time from a file without delimiters
#2
Re: Im trying to read records one at a time from a file without delimiters
Posted 15 November 2012 - 11:16 AM
Well there is only two ways you can know what is the beginning verses the end of each "token". You either have to insert a delimiter like a space (which sounds like what they want you to do) or keep track of the length of each token... for instance inserting "apple" and then storing "5" somewhere so when you read you know to read 5 characters.
So you might be missing an important detail somewhere.
So you might be missing an important detail somewhere.
#3
Re: Im trying to read records one at a time from a file without delimiters
Posted 15 November 2012 - 11:41 AM
You can write as a byte 5 than as bytes a p p l e
then as a byte 6 then as bytes o r a n g e
or use " ", "," "\t", "|", "/", ... as delimiters
then as a byte 6 then as bytes o r a n g e
or use " ", "," "\t", "|", "/", ... as delimiters
#4
Re: Im trying to read records one at a time from a file without delimiters
Posted 15 November 2012 - 11:47 AM
Quote
How do you make the program figure out where apple ends and orange begins? I'm also not allowed to write a separate index file. This seems impossible to me but supposedly people have figured this out before.
#5
Re: Im trying to read records one at a time from a file without delimiters
Posted 15 November 2012 - 11:56 AM
Yes we went throug this. Thanks g00se
http://www.dreaminco...1&#entry1746723
Please avoid double posting, you are wasting our time
http://www.dreaminco...1&#entry1746723
Please avoid double posting, you are wasting our time
Page 1 of 1
|
|

New Topic/Question
This topic is locked



MultiQuote





|