|
![]() |
Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming | |
some help in C++ coding
|
||
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) | |||||||||||||
|
Overclocker
Join Date: Jan 2005
Location: kuching, Sarawak, Malaysia
Posts: 46
Rep: 2
![]() Unique Rep: 2
Trader Rating: 0
|
Question :User can only enter a 5 digit number, cannot less or more than 5 digit.
Someone please, thank you.
__________________
:shades2: ♥♥ANDY♥♥
|
|||||||||||||
|
|
|
|
|
#2 (permalink) | ||||||||||
|
Linux Lobbyist
|
Hmmm, couldn't you do something like (keep in mind I only know java, so this may not port over to C++)...
int code; code = keyboard.ReadInt(); if (((code / 10000) > 9) || ((code / 10000) < 1)) { System.out.println ("You have entered an incorrect amount of digits"); } Where / is the div command... taking the nearest integer http://lab.privacy.cs.cmu.edu/course...e10/sld048.htm
__________________
Signatures are overrated.
Last edited by drummer4lifex : 08-06-06 at 02:36 PM. |
||||||||||
|
|
|
|
|
#3 (permalink) | |||||||||||
|
4.0ghz
|
I'm no c++ expert, but I'd try using scanf
Linky Where 'width' would be 5 So, you'd say something like this: (completely untested btw) float number; printf("Enter a 5-digit number:"); scanf(%5f,number); If number was a double, it should be scanf(%5lf,number); if that page is correct...
__________________
Overclocking in a nutshell: CyberDruid's BOOK | EvilXP's List of OCing Guides | DeathONator's Ultimate Overclocking Guide | The TOS Quote:
|
|||||||||||
|
|
|
|
#4 (permalink) | ||||||||||
|
Linux Lobbyist
|
I don't think you'd use a double, though...
__________________
Signatures are overrated.
|
||||||||||
|
|
|
|
|
#5 (permalink) | |||||||||||||
|
Overclocker
Join Date: Jan 2005
Location: kuching, Sarawak, Malaysia
Posts: 46
Rep: 2
![]() Unique Rep: 2
Trader Rating: 0
|
auh ~~ Thx alot of helping but not working >.< no idea how the code gonna be =(
__________________
:shades2: ♥♥ANDY♥♥
|
|||||||||||||
|
|
|
|
|
#6 (permalink) | ||||||||||
|
Linux Lobbyist
|
Is it text-based?
__________________
Signatures are overrated.
|
||||||||||
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|