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

Username:   Password: 
 RegisterRegister   
 How do you add names and highscores using files and changing the value if beaten?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TuringNewbie90




PostPosted: Sun Oct 16, 2016 4:20 pm   Post subject: How do you add names and highscores using files and changing the value if beaten?

I have a trouble assigning a certain score to a certain name. Is there a way to do so?
Also is there a command that detects if the string has an integer or not?
Thanks a lot!
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Sun Oct 16, 2016 9:59 pm   Post subject: RE:How do you add names and highscores using files and changing the value if beaten?

strint() will convert a string to an integer. strintok() will return true if the string is an integer (ie only characters 0-9). If you need to determine if a string has an integer in it, mixed with other characters, no, there isn't a command to do that, but you can write your own function that will do it.

There are many ways to assign a score to a name. You're really just saying 'these two variables go together'. Presumably you have many names with scores assigned to each. Any time you have lots of things, you'll probably want an array. Got lots of names? Make an array of names. Lots of scores? Make an array of scores. If you want to know the score of name[n], then look at score[n].
If you already understand records, you can use those to bind name and score together into one variable and use an array of that, but I wouldn't bother learning that yet if you don't already know it.

As for files, well, just get it working without files for now. Once you have that, we can worry about files.
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  [ 2 Posts ]
Jump to:   


Style:  
Search: