Computer Science Canada

File Input/output help needed

Author:  adamonfire [ Wed Feb 16, 2005 9:46 am ]
Post subject:  File Input/output help needed

hey,
I'm insanly stuck. I need to figure out how to read in a file and then output all the letters that have "s" in them one word per line. I know i'm going to need a counted loop but this thing is just driving me around the bend. If anyone could help at all it would be greatly appreacited.

Author:  Tony [ Wed Feb 16, 2005 10:41 am ]
Post subject: 

first you get the data from the file

you may store the data in an array, but that is not neccessary. Analyze words as they stream in.

use index() function to check if the word has a "s" substring in it or not.

Author:  Martin [ Wed Feb 16, 2005 10:43 am ]
Post subject:  Re: File Input/output help needed

adamonfire wrote:
hey,
I'm insanly stuck. I need to figure out how to read in a file and then output all the letters that have "s" in them one word per line. I know i'm going to need a counted loop but this thing is just driving me around the bend. If anyone could help at all it would be greatly appreacited.


Hate to break it to ya, but the only letter that has s in it is, well, s.

Author:  cycro1234 [ Wed Feb 16, 2005 11:51 am ]
Post subject: 

LOL

Author:  Tony [ Wed Feb 16, 2005 12:05 pm ]
Post subject:  Re: File Input/output help needed

martin wrote:
the only letter that has s in it is, well, s.

good call
Turing:

var fileID:int
open: fileID, "output.txt", put
loop
   put: fileID, "s"
   exit when Rand.Int(0,10)=10
end loop
close: fileID

Wink

Author:  Drakain Zeil [ Wed Feb 16, 2005 3:39 pm ]
Post subject: 

Hah! nice.

Anyway, for the WORD, make the string into variables, and do this...

Index for spaces, move in a for loop from the begining to the end, depending on what set of spaces the s is between, that is the word you use. I could imagine some other ways of doing this, but this is the first to come to mind.


: