Validating numeric values in c sharp

posted by | Leave a comment

This is actually an infinite loop, but it is only broken if the user actually enters the right length of security code! Many times we need to ask for text or character data from the user.In that case, we will need to use the string.h library, which is used to work with string and character data.C is a powerful language, but it will allow users to input garbage.

At this point, nothing stops the user from entering the entire text of War and Peace as one long string!We already used scanf (in the code above) to read user input.We'll use scanf here, but will make sure that the item entered is actually a single-digit integer.Before we can use string functions, we need to include the string.h header file before any function.The menu variable is declared as a character array instead of an integer.

Leave a Reply

Free adult web chats