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

Username:   Password: 
 RegisterRegister   
 File Input/output help needed
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
adamonfire




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Wed Feb 16, 2005 10:41 am   Post subject: (No 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.
Martin




PostPosted: 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.
cycro1234




PostPosted: Wed Feb 16, 2005 11:51 am   Post subject: (No subject)

LOL
Tony




PostPosted: 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
Drakain Zeil




PostPosted: Wed Feb 16, 2005 3:39 pm   Post subject: (No 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.
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  [ 6 Posts ]
Jump to:   


Style:  
Search: