Computer Science Canada

charAt for Turing

Author:  xtreemboarder [ Tue May 16, 2006 4:07 pm ]
Post subject:  charAt for Turing

is there a function that can get a single character from a word or phrase... like you give it a number which represents the address (sort of) and it just returns the character... i know theres such a thing in Java which is called charAt... and its a great little tool.

so for example... in Java I would write something like this

String word = "canada";
char ch = word.charAt (3);
c.print (ch);

note that in Java, the first character starts with 0.

Author:  xtreemboarder [ Tue May 16, 2006 4:10 pm ]
Post subject: 

btw i forgot to mention that that example will return "a".

c a n a d a
0 1 2 3 4 5
^
^

Author:  Clayton [ Tue May 16, 2006 4:14 pm ]
Post subject: 

check the Turing Walkthrough's string manipulation tutorial, but basically
Turing:

var word:string:= "Canada"
put word(4)

this will output the letter "a"

Author:  xtreemboarder [ Tue May 16, 2006 4:24 pm ]
Post subject: 

omg man... i couldnt find that anywhere and it ended up to be so simple...

thanks man


: