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

Username:   Password: 
 RegisterRegister   
 Trying to count the amount of words in a line of text and I'm a little stuck
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TrueRoze




PostPosted: Thu Nov 28, 2019 9:31 am   Post subject: Trying to count the amount of words in a line of text and I'm a little stuck

What is it you are trying to achieve?
I have a text file, and I'm trying to:
1 - count the amount of words in the line
2 - run a for loop for that amount of characters
3 - set a boolean to true if there are more than 7 words
4 - put the text on a new line if there are more than 7 words, else continue putting the text until there are 7 words on a line

What is the problem you are having?
I'm not sure how to count the amount of words on a line. I had an idea, counting the amount of spaces and using a boolean to store whether there's less or more than 7 words per line, but I can't figure out how to do it


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
This is as far as I got, I'm really stuck on this

Turing:

var stream : int
open : stream, "newtext.txt", get
assert stream > 0
loop
    exit when eof (stream)
    get : stream, line : *


Please specify what version of Turing you are using
4.1.1
Sponsor
Sponsor
Sponsor
sponsor
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  [ 1 Posts ]
Jump to:   


Style:  
Search: