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

Username:   Password: 
 RegisterRegister   
 counting the number of words in a string
Index -> Programming, Turing -> Turing Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
daneck13




PostPosted: Thu Mar 17, 2011 12:14 pm   Post subject: Re: counting the number of words in a string

yes but then what do i do to change it from being always false
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Thu Mar 17, 2011 12:22 pm   Post subject: RE:counting the number of words in a string

code:
if words(i..x)=" "


You're specifying a range here. I dunno how Turing would handle this, but it looks like 'If this section of this string is a space' rather than 'if this character of this string is a space'.

For example, if our string is 'Hello world', and x is 6, Turing will compare 'Hello '* to ' '. See how it isn't equal?

*This may vary depending on weather or not Turing zero-indexes strings. I don't remember.
Tony




PostPosted: Thu Mar 17, 2011 12:23 pm   Post subject: RE:counting the number of words in a string

You change it to something that has a chance at being true at least sometimes.

The problem here is that you are asking (in a way of writing code) for a computer to do something that is different from what you _think_ you are asking. It might be subtle and you might have to print out some actual values to see what's going on. The hint is that it's always false, your job is to figure out why.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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 2 of 2  [ 18 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: