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 > Application Programming

Reply
 
LinkBack Thread Tools
Old 06-10-05   #1 (permalink)
XBox 360 Gamer
 
Chim3ra's Avatar
 
intel nvidia

Join Date: Mar 2005
Location: Rota, Espana
Posts: 4,368

Rep: 431 Chim3ra is a proven memberChim3ra is a proven memberChim3ra is a proven memberChim3ra is a proven memberChim3ra is a proven member
Unique Rep: 279
FAQs Submitted: 7
Folding Team Rank: 890
Trader Rating: 3
Default Having trouble with this code

#include <stdio.h>

int main(void)
{
int a, b, c, sum;

printf("Input three integers: ");
scanf(%d, %d, %d, a, b, c);
sum = (((a + b + c) * 2) + 7);
printf("Twice the sum of your integers plus 7 is sum");
}

I tried different things but it says the variables aren't defined but i thought thats what scanf was for? so in my eyes it's clearly defined, and if i change other things i get another error that pops up the "send error report" dialogue box. Anyone know what I'm doing wrong?
__________________
Read and heed, The Forum TS!!!
Trouble finding the FAQ page? Go Here
Help us, help you. Fill out your System Specs.
New to the art of Overclocking? Read these to get you started in the right direction. AMD Intel
XBox Live Gamertag: Wikk3d

System: The Stocker
CPU
Q9300
Motherboard
EVGA 750 SLI FTW
Memory
4GB G.Skill DDR2-800
Graphics Card
EVGA 9800 GTX KO
Hard Drive
Seagate Barracuda ES.2 ST3250310NS
Sound Card
SB X-FI Platinum
Power Supply
FSP Epsilon 600
Case
Antec P180
CPU cooling
Xigmatek HDT-S1283
GPU cooling
Stock
OS
Windows Vista SP1
Monitor
Dell 2405 FPW
Chim3ra is offline I fold for Overclock.net Overclocked Account Chim3ra's Gallery   Reply With Quote
Old 06-10-05   #2 (permalink)
serial badger molester
 
intel ati

Join Date: Jul 2004
Posts: 5,095

FAQs Submitted: 2
Hardware Reviews: 3
Trader Rating: 9
Default

Why you put int before main(void)?
__________________


System: :) x2
CPU
E8400
Motherboard
Asus P5Q Pro
Memory
4GB Team Xtreem 1066Mhz
Graphics Card
2x Asus EAH4850 Crossfire
Hard Drive
250GB Seagate 7200.10
Sound Card
Asus Xonar D2X
Power Supply
Seasonic S12-600
Case
Lian Li PC-A70B
CPU cooling
Thermalright Ultra-120A
GPU cooling
stock
OS
Vista Business x64
Monitor
Dell SP2208WFP
muffin is offline Overclocked Account   Reply With Quote
Old 06-10-05   #3 (permalink)
Bifford
 
BFRD's Avatar
 
intel nvidia

Join Date: Dec 2004
Location: Carrollton, TX
Posts: 4,414

FAQs Submitted: 8
Folding Team Rank: 31
Hardware Reviews: 2
Trader Rating: 11
Default

Quote:
Originally Posted by muffin
Why you put int before main(void)?
probably should be void as the function doesn't return anything
__________________
Helpful Posts (Hopefully )
Overclocker's Calculator
Photo Editing - B&W w/Color Accents

System: Main Rig
CPU
E6700 Conroe
Motherboard
Abit QuadGT
Memory
2GB G.Skill PC2 8000 (HZ)
Graphics Card
EVGA 8800GTX
Hard Drive
150 GB Raptor X / 300GB Storage
Sound Card
Audigy 2 ZS
Power Supply
PCP&C Silencer 750
Case
Sigma Shark
CPU cooling
Stock (for now)
GPU cooling
Stock
OS
Vista Ultimate
Monitor
Dual Samsung 204b

Last edited by BFRD : 06-10-05 at 06:43 PM.
BFRD is offline I fold for Overclock.net Overclocked Account BFRD's Gallery   Reply With Quote
Old 06-10-05   #4 (permalink)
4.0ghz
 
ouroboros1827's Avatar
 
intel

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

Rep: 258 ouroboros1827 is a proven memberouroboros1827 is a proven memberouroboros1827 is a proven member
Unique Rep: 190
Folding Team Rank: 1746
Hardware Reviews: 2
Trader Rating: 0
Default

i'm a noob. slay me. this post isn't worth taking up your screen, so i deleted it.

better post can be found below
Attached Files
File Type: txt lov.c.txt (227 Bytes, 32 views)
__________________
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

Last edited by ouroboros1827 : 06-10-05 at 07:06 PM.
ouroboros1827 is offline I fold for Overclock.net Overclocked Account   Reply With Quote
Old 06-10-05   #5 (permalink)
serial badger molester
 
intel ati

Join Date: Jul 2004
Posts: 5,095

FAQs Submitted: 2
Hardware Reviews: 3
Trader Rating: 9
Default

I was gonna say, never seen it done like that...

void main() or void main(void) I think?
__________________


System: :) x2
CPU
E8400
Motherboard
Asus P5Q Pro
Memory
4GB Team Xtreem 1066Mhz
Graphics Card
2x Asus EAH4850 Crossfire
Hard Drive
250GB Seagate 7200.10
Sound Card
Asus Xonar D2X
Power Supply
Seasonic S12-600
Case
Lian Li PC-A70B
CPU cooling
Thermalright Ultra-120A
GPU cooling
stock
OS
Vista Business x64
Monitor
Dell SP2208WFP
muffin is offline Overclocked Account   Reply With Quote
Old 06-10-05   #6 (permalink)
XBox 360 Gamer
 
Chim3ra's Avatar
 
intel nvidia

Join Date: Mar 2005
Location: Rota, Espana
Posts: 4,368

Rep: 431 Chim3ra is a proven memberChim3ra is a proven memberChim3ra is a proven memberChim3ra is a proven memberChim3ra is a proven member
Unique Rep: 279
FAQs Submitted: 7
Folding Team Rank: 890
Trader Rating: 3
Default

none of that is working for some reason. the reason i have it set up in that manner (int main(void)) is because thats how the text states to write it up. originally when i built the program it gave me a couple of errors but i was missing a quotation mark and a semicolon. after that it built fine but the error was when i went to debug it. it would display the user input line and when i hit enter it would fail.
__________________
Read and heed, The Forum TS!!!
Trouble finding the FAQ page? Go Here
Help us, help you. Fill out your System Specs.
New to the art of Overclocking? Read these to get you started in the right direction. AMD Intel
XBox Live Gamertag: Wikk3d

System: The Stocker
CPU
Q9300
Motherboard
EVGA 750 SLI FTW
Memory
4GB G.Skill DDR2-800
Graphics Card
EVGA 9800 GTX KO
Hard Drive
Seagate Barracuda ES.2 ST3250310NS
Sound Card
SB X-FI Platinum
Power Supply
FSP Epsilon 600
Case
Antec P180
CPU cooling
Xigmatek HDT-S1283
GPU cooling
Stock
OS
Windows Vista SP1
Monitor
Dell 2405 FPW
Chim3ra is offline I fold for Overclock.net Overclocked Account Chim3ra's Gallery   Reply With Quote
Old 06-10-05   #7 (permalink)
Lord of the Chicken Wings
 
VulcanDragon's Avatar
 
intel nvidia

Join Date: Aug 2004
Location: Columbus, OH
Posts: 5,218
Blog Entries: 25

FAQs Submitted: 1
Trader Rating: 0
Default

It doesn't look like you're using scanf correctly. Take a look at this page for some tips and examples on scanf:

http://www.cplusplus.com/ref/cstdio/scanf.html
__________________
Vulcan Dragon
Core i7 920 @ 3.8 GHz
Currently Playing: Grand Theft Auto 4 (X360); Rock Band 2 (X360); Far Cry 2 (PC)
XBox Live Gamertag: Vulcan Draggon

System: Vulcan's New Hotness
CPU
Core i7 920 @ 3.8 GHz
Motherboard
Asus P6T Deluxe
Memory
6GB Corsair XMS3 DDR3-1333
Graphics Card
EVGA GTX 260 (216)
Hard Drive
300GB Velociraptor (main)
Power Supply
ThermalTake 850W
Case
Lian Li PC-6077
CPU cooling
TRUE 120
OS
Vista Ultimate x64 SP1
Monitor
Gateway FHD2400
VulcanDragon is offline Overclocked Account   Reply With Quote
Old 06-10-05   #8 (permalink)
XBox 360 Gamer
 
Chim3ra's Avatar
 
intel nvidia

Join Date: Mar 2005
Location: Rota, Espana
Posts: 4,368

Rep: 431 Chim3ra is a proven memberChim3ra is a proven memberChim3ra is a proven memberChim3ra is a proven memberChim3ra is a proven member
Unique Rep: 279
FAQs Submitted: 7
Folding Team Rank: 890
Trader Rating: 3
Default

Quote:
Originally Posted by ouroboros1827
no no no.
you have:
int main(void)
put:
void main()

your main() doesn't return anything, so keep it void, but args go in the parentheses. you don't have any, so don't put any in there

change that line.

EDIT: actually (now that i remember c++), you should make main(): int main(), and return 0;

it's usually better to keep it that way. also gcc doesn't like it void main(). idk why.

also, scanf should be:

scanf("%d", a);

code attached.
isn't the return 0 already part of the header though? my book says its not necessary to put it in there since it's already built in
__________________
Read and heed, The Forum TS!!!
Trouble finding the FAQ page? Go Here
Help us, help you. Fill out your System Specs.
New to the art of Overclocking? Read these to get you started in the right direction. AMD Intel
XBox Live Gamertag: Wikk3d

System: The Stocker
CPU
Q9300
Motherboard
EVGA 750 SLI FTW
Memory
4GB G.Skill DDR2-800
Graphics Card
EVGA 9800 GTX KO
Hard Drive
Seagate Barracuda ES.2 ST3250310NS
Sound Card
SB X-FI Platinum
Power Supply
FSP Epsilon 600
Case
Antec P180
CPU cooling
Xigmatek HDT-S1283
GPU cooling
Stock
OS
Windows Vista SP1
Monitor
Dell 2405 FPW
Chim3ra is offline I fold for Overclock.net Overclocked Account Chim3ra's Gallery   Reply With Quote
Old 06-10-05   #9 (permalink)
4.0ghz
 
ouroboros1827's Avatar
 
intel

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

Rep: 258 ouroboros1827 is a proven memberouroboros1827 is a proven memberouroboros1827 is a proven member
Unique Rep: 190
Folding Team Rank: 1746
Hardware Reviews: 2
Trader Rating: 0
Default

alright. i think i have regained some knowledge through this. thank you.

FIXED NEW code attached.
Attached Files
File Type: txt lov.c.txt (217 Bytes, 27 views)
__________________
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 I fold for Overclock.net Overclocked Account   Reply With Quote
Old 06-10-05   #10 (permalink)
XBox 360 Gamer
 
Chim3ra's Avatar
 
intel nvidia

Join Date: Mar 2005
Location: Rota, Espana
Posts: 4,368

Rep: 431 Chim3ra is a proven memberChim3ra is a proven memberChim3ra is a proven memberChim3ra is a proven memberChim3ra is a proven member
Unique Rep: 279
FAQs Submitted: 7
Folding Team Rank: 890
Trader Rating: 3
Default

Thanks guys, all your inputs have helped. I'm still having one more problem though. The sum won't print. when i use %d in front of sum it kicks out some kind of crazy number that isn't correct. it should be 31, but i'm getting like 21XXX. any other ideas?
__________________
Read and heed, The Forum TS!!!
Trouble finding the FAQ page? Go Here
Help us, help you. Fill out your System Specs.
New to the art of Overclocking? Read these to get you started in the right direction. AMD Intel
XBox Live Gamertag: Wikk3d

System: The Stocker
CPU
Q9300
Motherboard
EVGA 750 SLI FTW
Memory
4GB G.Skill DDR2-800
Graphics Card
EVGA 9800 GTX KO
Hard Drive
Seagate Barracuda ES.2 ST3250310NS
Sound Card
SB X-FI Platinum
Power Supply
FSP Epsilon 600
Case
Antec P180
CPU cooling
Xigmatek HDT-S1283
GPU cooling
Stock
OS
Windows Vista SP1
Monitor
Dell 2405 FPW
Chim3ra is offline I fold for Overclock.net Overclocked Account Chim3ra's Gallery   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 03:26 AM.


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.37578 seconds with 9 queries