Computer Science Canada string to integer? |
Author: | noobsauce [ Sun Nov 09, 2008 6:24 pm ] | ||||||
Post subject: | string to integer? | ||||||
Ok, I am to make a program that askes the user to enter his name and then separate him into 2 catagories according to his first letter of last name. I want to convert the letter into integer and use the ASCII table to find what it is. But i can't convert it to integer...? here is my code so far
Is there a special function to do it? I tried to do it directly:
it says error anyways... Mod Edit: Please remember Code Tags. Thanks
|
Author: | TheGuardian001 [ Sun Nov 09, 2008 7:36 pm ] | ||
Post subject: | Re: string to integer? | ||
there is actually a command built into the language used for this.
ord goes from a letter to its ASCII character, while chr does the opposite and converts ASCII codes into letters. |
Author: | noobsauce [ Sun Nov 09, 2008 8:35 pm ] | ||
Post subject: | Re: string to integer? | ||
Thanks it works, but how do i fix
It doesn't work if the last letter was repeated in the name |
Author: | pavol [ Sun Nov 09, 2008 10:29 pm ] | ||||
Post subject: | Re: string to integer? | ||||
I am assuming that your code:
is used for finding the length of the username string. An easier way of doing this is to simply write:
|