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

Username:   Password: 
 RegisterRegister   
 help with length function
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Michael




PostPosted: Sun Nov 27, 2005 7:31 pm   Post subject: help with length function

hey people
i have this program


code:


    var name : string

    put "Questio 2"
    put " "
    put "Please enter your full name:"
    get name

    put "The length of your name is ", length (name)



the problem is.. the length function only counts the characters untill there's a space so now it only displays the first name and not the second name because of the space
how do i make it so it counts the space and what's after
Sponsor
Sponsor
Sponsor
sponsor
Dan




PostPosted: Sun Nov 27, 2005 7:40 pm   Post subject: (No subject)

the problem is not with the length function but with the gets fuction. It is only inputing the 1st string.

What you need to do is replace gets name with gets name:* if i rember how to use the gets function in turing right. If that dose not work check the manual on gets and see how to input a line rather then a word.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Michael




PostPosted: Sun Nov 27, 2005 7:45 pm   Post subject: (No subject)

yep thanks
just had to add * after get

code:

    var name : string
    put " "
    put "Please enter your full name:"
    get name : *
var name2 : string := name
    put "The length of your name is ", length(name2)
iker




PostPosted: Sun Nov 27, 2005 7:54 pm   Post subject: (No subject)

Your new name2 variable is just a waste of time... You could have just as easily just put
code:

    var name : string
    put "Please enter your full name:"
    get name:*
    put "The length of your name is ", length (name)
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  [ 4 Posts ]
Jump to:   


Style:  
Search: