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

Username:   Password: 
 RegisterRegister   
 Removing Underscores from Strings
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
CWRules




PostPosted: Tue Apr 07, 2009 4:17 pm   Post subject: Removing Underscores from Strings

I'm having a slight problem with my loading system. I have several strings with multiple words, and when I load them from the file they have underscores instead of spaces. eg. "Sutton West" becomes "Sutton_West" Is there a way around this? Thanks. (I have a feeling that this will be a very obvious and simple answer)

The code as is:

Turing:
        open : data, "Data.txt", get
        get : data, pname1
        get : data, pname2
        get : data, gender
        get : data, birthday
        get : data, birthmon
        get : data, birthyr
        get : data, hometown : *
        get : data, country : *
        close : data


The last two variables are the ones causing the problem.

Mod Edit: Remember to use syntax tags! Thanks Smile
code:
[syntax="turing"]Code Here[/syntax]
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Tue Apr 07, 2009 5:36 pm   Post subject: RE:Removing Underscores from Strings

Iterate over the string, replacing every instance of the underscore character with the space character. Remember that you can read or set the value of a single character in a string by indexing it like an array:

Turing:

var c : char := myString ( 12 )
CWRules




PostPosted: Tue Apr 07, 2009 9:04 pm   Post subject: Re: Removing Underscores from Strings

I don't quite get it. I see what you mean but don't see exactly how it would be done. Could you explain? Thanks. (Man, I feel stupid today)
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  [ 3 Posts ]
Jump to:   


Style:  
Search: