| Jill Jill (3) | |||
|
Ok, I'm having a little bit of a hard time here. You see, I was planning to loop until the user enters a valid input. I only need a numeric input, nothing else. THE POINT IS: I kind of did it. But still, you see, while using the isalpha and the isalnum functions for verification, the cout repeats itself into the number of characters invalid input is. But that's not what I want :( Here's my code:
You could say my keywords for searching fail 'cuz I couldn't find anything in regards to this matter. I just need an incy weency ounce of your help. I'd be happy if you could provide me links over an article I could read involving this, happier if you could provide me an example I can model after, and the happiest thing in this moment if you could just get to the point :PP. Thanks. Do understand that I'm still a newbie to programming. I'm trying my best to learn stuff. | |||
|
Last edited on
|
|||
| Prashant Gupta PG (104) | |||
try the following program,it works
enjoy programming :) | |||
|
|
|||
| Jill Jill (3) | ||
|
Thank you but... I wanted to loop until the user has inputted a valid value. Let's say:
Something like that, it loops until a valid value is inputted. Thanks anyways. | ||
|
Last edited on
|
||
| Prashant Gupta PG (104) | |
| The function isalpha() works only for characters. this actually compares the ascii values of the passed value. The ascii value of characters are 65-90(for capital letters) and 97-122(for small letters).for example u enter a value in an int number 89. this is a value of 'Y' therefore the function will turn to TRUE. this is what creating a problem in your program. | |
|
|
|
| Jill Jill (3) | |
|
Owwwkay. That still didn't get into my puny brain. Thanks for explaining me what those functions are for. Just saw them off from somewhere and thought I might as well use it to distinguish characters from numerals. Guess not. Thank you :) Your code works well for numbers greater than 100 but, when, let's say, user inputs letters, it's an infinite loop. Wonder what I can do to make my program operate similar to the sample output I posted above? Imma keep trying :PP Thanks for replying to my queries :) | |
|
|
|