| Nuc (29) | |||
I want the loop to repeat if there is a letter in nx, because 5a, 5x, 5b, etc. will work too. How do I do that? | |||
|
|
|||
| Nuc (29) | |
| bump. | |
|
|
|
| Nuc (29) | |
|
bump again. Come on, it can't be that hard. | |
|
|
|
| The DooD (4) | |
|
Well as far as I know (because I'm only a beginner too) "nx" can never be a letter, because the nx variable type is an int. This means that nx can only store integer values in that scope. If you made it a char instead of an int then it would be able to store letters and numbers, but it would only be able to store one at a time (so if you try and store 'ab' in a char, it will only store 'b'). Also, doesn't your compiler throw a spazz if your main function doesn't return an int? | |
|
Last edited on
|
|
| sasanet (117) | |||||
|
i'm not shure but maybe problem is here: YOURE CODE:
MY CODE
| |||||
|
Last edited on
|
|||||
| Nuc (29) | |
|
The DooD, no, since it's VOID main(), it doesn't require return 0, that would be if I'd put INT main() instead, that would require return 0. Since it's not a complicated program I don't have to inform the system about the result of my program. Thanks, changing it to char helped. However if I type 5k or k5 or any other letter (not number) it prints "Type 5: " two times. How do I prevent that? | |
|
|
|
| Bazzy (6281) | |
|
void main is non-standard, C++ requires int main. As The DooD said, you need to read a character if you want to check whether it's a letter ( using isalpha function ) If instead want to read an integer and skip invalid input (like letters or any other non-numeric character), see http://www.cplusplus.com/forum/articles/6046/ | |
|
|
|