Computer Science Canada

help with length function

Author:  Michael [ 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

Author:  Dan [ Sun Nov 27, 2005 7:40 pm ]
Post 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.

Author:  Michael [ Sun Nov 27, 2005 7:45 pm ]
Post 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)

Author:  iker [ Sun Nov 27, 2005 7:54 pm ]
Post 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)


: