Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming

Reply
 
LinkBack Thread Tools
Old 08-06-06   #1 (permalink)
Overclocker
 
ANDY_JEFF's Avatar
 
amd ati

Join Date: Jan 2005
Location: kuching, Sarawak, Malaysia
Posts: 46

Rep: 2 ANDY_JEFF Unknown
Unique Rep: 2
Trader Rating: 0
Default some help in C++ coding

Question :User can only enter a 5 digit number, cannot less or more than 5 digit.

Someone please, thank you.
__________________
:shades2: ♥♥ANDY♥♥

System: My System
CPU
AMD Athlon 64 +3000
Motherboard
Gigabyte K8N-SLI
Memory
Kingston Hyper X dual kid
Graphics Card
ATI X1600XT
Hard Drive
Maxtor 250GB
Sound Card
CREATIVE life
Power Supply
Enermax 350w
Case
ATX-TOWER CASING
CPU cooling
Stock
GPU cooling
CoolerMaster CoolViva Pro
OS
XP PRO
Monitor
VIEW SONIC
ANDY_JEFF is offline   Reply With Quote
Old 08-06-06   #2 (permalink)
Linux Lobbyist
 
drummer4lifex's Avatar
 
amd ati

Join Date: May 2006
Location: Champaign, IL
Posts: 1,247

Rep: 102 drummer4lifex is acknowledged by manydrummer4lifex is acknowledged by many
Unique Rep: 73
FAQs Submitted: 6
Trader Rating: 2
Default

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.

System: My System
CPU
Opteron 165 CCBBE 0610
Motherboard
DFI LanParty Ultra-D
Memory
2x 1GB OCZ Gold DDR 500
Graphics Card
Sapphire X1900XT 512MB
Hard Drive
160GB WD Caviar
Power Supply
Hiper 580W UV Blue
CPU cooling
Swiftech Apogee
GPU cooling
Danger Den MAZE4 LP
OS
Ubuntu

Last edited by drummer4lifex : 08-06-06 at 02:36 PM.
drummer4lifex is offline   Reply With Quote
Old 08-06-06   #3 (permalink)
4.0ghz
 
ouroboros1827's Avatar
 
intel

Join Date: Nov 2004
Location: Northern VA
Posts: 2,393

Rep: 258 ouroboros1827 is a proven memberouroboros1827 is a proven memberouroboros1827 is a proven member
Unique Rep: 190
Hardware Reviews: 1
Trader Rating: 0
Default

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:

In other words: Removed code is debugged code, and it certainly doesn't use any memory or CPU time; so even better if you don't write it.

System: Macbook
CPU
Core 2 Duo 2Ghz
Motherboard
Apple
Memory
4Gb
Graphics Card
GMA 950
Hard Drive
80Gb
Sound Card
Intel HD Audio (?)
Case
White & Shiny
OS
OS X 10.5
Monitor
13.3" 1280x800
ouroboros1827 is offline Overclocked Account   Reply With Quote
Old 08-06-06   #4 (permalink)
Linux Lobbyist
 
drummer4lifex's Avatar
 
amd ati

Join Date: May 2006
Location: Champaign, IL
Posts: 1,247

Rep: 102 drummer4lifex is acknowledged by manydrummer4lifex is acknowledged by many
Unique Rep: 73
FAQs Submitted: 6
Trader Rating: 2
Default

I don't think you'd use a double, though...
__________________
Signatures are overrated.

System: My System
CPU
Opteron 165 CCBBE 0610
Motherboard
DFI LanParty Ultra-D
Memory
2x 1GB OCZ Gold DDR 500
Graphics Card
Sapphire X1900XT 512MB
Hard Drive
160GB WD Caviar
Power Supply
Hiper 580W UV Blue
CPU cooling
Swiftech Apogee
GPU cooling
Danger Den MAZE4 LP
OS
Ubuntu
drummer4lifex is offline   Reply With Quote
Old 08-06-06   #5 (permalink)
Overclocker
 
ANDY_JEFF's Avatar
 
amd ati

Join Date: Jan 2005
Location: kuching, Sarawak, Malaysia
Posts: 46

Rep: 2 ANDY_JEFF Unknown
Unique Rep: 2
Trader Rating: 0
Default

auh ~~ Thx alot of helping but not working >.< no idea how the code gonna be =(
__________________
:shades2: ♥♥ANDY♥♥

System: My System
CPU
AMD Athlon 64 +3000
Motherboard
Gigabyte K8N-SLI
Memory
Kingston Hyper X dual kid
Graphics Card
ATI X1600XT
Hard Drive
Maxtor 250GB
Sound Card
CREATIVE life
Power Supply
Enermax 350w
Case
ATX-TOWER CASING
CPU cooling
Stock
GPU cooling
CoolerMaster CoolViva Pro
OS
XP PRO
Monitor
VIEW SONIC
ANDY_JEFF is offline   Reply With Quote
Old 08-06-06   #6 (permalink)
Linux Lobbyist
 
drummer4lifex's Avatar
 
amd ati

Join Date: May 2006
Location: Champaign, IL
Posts: 1,247

Rep: 102 drummer4lifex is acknowledged by manydrummer4lifex is acknowledged by many
Unique Rep: 73
FAQs Submitted: 6
Trader Rating: 2
Default

Is it text-based?
__________________
Signatures are overrated.

System: My System
CPU
Opteron 165 CCBBE 0610
Motherboard
DFI LanParty Ultra-D
Memory
2x 1GB OCZ Gold DDR 500
Graphics Card
Sapphire X1900XT 512MB
Hard Drive
160GB WD Caviar
Power Supply
Hiper 580W UV Blue
CPU cooling
Swiftech Apogee
GPU cooling
Danger Den MAZE4 LP
OS
Ubuntu
drummer4lifex is offline   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -4. The time now is 01:09 PM.


Overclock.net is a Carbon Neutral Site Creative Commons License Internet Security By ControlScan

Terms of Service / Forum Rules | Privacy Policy | Advertising | Become an Official Vendor
Copyright © 2008 Shogun Interactive Development. Most rights reserved.
Page generated in 0.23777 seconds with 8 queries