Computer Science Canada Using String Manipulation to Change a Space to an Underscore |
Author: | Four [ Tue Jan 20, 2009 5:37 pm ] | ||||
Post subject: | Using String Manipulation to Change a Space to an Underscore | ||||
Well, I'm creating a game and for my highscore table, when they enter their name, if they enter a space, I want the space to convert to an underscore so the highscores wont get messed up. When I write the code, it says the left side is not a variable and hence cannot be assigned to.
Edit: I just tried the code below, but it does not change the space to an underscore
Thanks |
Author: | nike52 [ Tue Jan 20, 2009 7:29 pm ] |
Post subject: | Re: Using String Manipulation to Change a Space to an Underscore |
try ' ' instead of " "? |
Author: | TheGuardian001 [ Tue Jan 20, 2009 8:41 pm ] | ||
Post subject: | Re: Using String Manipulation to Change a Space to an Underscore | ||
the problem is not with the type of quotes. I believe Turing accepts either type of quotes for strings. The problem is that strNamSub(n) is not a variable, it is an index of a variable. you will probably need to totally reset your string to include "_". to reset a string character by character:
all you need to do at that point is to check what character is going in before adding it to the new string |