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

Username:   Password: 
 RegisterRegister   
 Error proofing user input
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
tecnikal




PostPosted: Sat May 30, 2009 1:19 pm   Post subject: Error proofing user input

My program asks for a user to input integer values. Is there a way, just in case a user inputs a real number with decimal places, to make the program check if it is a real number or an integer value?


The numbers MUST be integer values otherwise it will mess up the program.
Sponsor
Sponsor
Sponsor
sponsor
DtY




PostPosted: Sat May 30, 2009 1:38 pm   Post subject: RE:Error proofing user input

the function strintok(String):Boolean will tell you if it can be converted to an integer.
Dusk Eagle




PostPosted: Sat May 30, 2009 3:47 pm   Post subject: Re: Error proofing user input

So, as DtY implied, you should get the input as a string and then use strintok (input), strint (input), strrealok (input), and strreal (input) to convert the variable to the appropriate type.
DtY




PostPosted: Sat May 30, 2009 3:52 pm   Post subject: Re: Error proofing user input

Dusk Eagle @ Sat May 30, 2009 3:47 pm wrote:
So, as DtY implied, you should get the input as a string and then use strintok (input), strint (input), strrealok (input), and strreal (input) to convert the variable to the appropriate type.

Oh yah, I should have mentioned you need to get input as a string. Thanks
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  [ 4 Posts ]
Jump to:   


Style:  
Search: