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 01-09-08   #1 (permalink)
First Time Build
 
Chani.-'s Avatar
 
intel nvidia

Join Date: Sep 2007
Posts: 300

Rep: 9 Chani.- Unknown
Unique Rep: 9
Trader Rating: 0
Default C++ Help

Code:
#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
	printf("-Fahrenheit to Celsius Converter-\n");
	printf("Fahrenheit to convert : ");
	int f = scanf_s("%d",f);
	int c = (5/9)*(f-32);
	printf("%d Degrees in Celsius is %d Degrees\n",f,c);
	return 0;
  return 0;
}
when i build this in Visual Studios C++ 2008 I get this error
Quote:
: warning C4700: uninitialized local variable 'f' used
what am i doing wrong?
__________________
-- First Build Ever --
аnnїніlатοя

Quote:
Originally Posted by RoadRebel View Post
I'm actually gurious what extreme gaming is? Playing games while kyakiing down whitewater?

System: аnnїніlатοя
CPU
Intel Q6600 B3 2.4Ghz
Motherboard
Asus P5N-E SLI
Memory
OCZ Reaper HPC PC2-6400 (4 x 1GB)
Graphics Card
eVGA 8600GT 256MB
Hard Drive
Western Digital 500GB
Sound Card
Onboard
Power Supply
Thermaltake Toughpower 700W (60A)
Case
Cooler Master 690
CPU cooling
Tuniq Tower 120
GPU cooling
Stock
OS
Windows Vista Ultimate 64-Bit
Chani.- is offline   Reply With Quote
Old 01-09-08   #2 (permalink)
First Time Build
 
BRISKbaby's Avatar
 
intel nvidia

Join Date: Mar 2006
Posts: 582

Rep: 44 BRISKbaby is acknowledged by some
Unique Rep: 41
Folding Team Rank: 158
Trader Rating: 1
Default

Quote:
Originally Posted by Chani.- View Post
Code:
#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
	printf("-Fahrenheit to Celsius Converter-n");
	printf("Fahrenheit to convert : ");
	int f = scanf_s("%d",f);
	int c = (5/9)*(f-32);
	printf("%d Degrees in Celsius is %d Degreesn",f,c);
	return 0;
  return 0;
}
when i build this in Visual Studios C++ 2008 I get this error


what am i doing wrong?
I think you are using "f" before it's being declared when you try to "scanf_s("%d",f);" Try to initialize it to 0 then use it. "c" should be fine since you're not using "c" on that line.
__________________

And God said:
∇ • E = ρ / εo; ∇ • B = 0; ∇ x E = - ∂B/∂t; ∇ x B = μoJ + μoεo∂E/∂t;
and there was light .


System: Quantized Quad
CPU
Q6600 (G0)
Motherboard
Asus P5k Deluxe (WiFi/AP)
Memory
2GB Crucial DDR2 1065
Graphics Card
8600GT
Hard Drive
2 X Wd2500KS
Sound Card
XFi - XtremeMusic
Power Supply
PC Power Cooling Silent 750W
Case
Aluminus
CPU cooling
Apogee CPU Block
OS
XP / Vista Ultimate
Monitor
Dell 20" Widescreen
BRISKbaby is offline I fold for Overclock.net   Reply With Quote
Old 01-09-08   #3 (permalink)
First Time Build
 
Chani.-'s Avatar
 
intel nvidia

Join Date: Sep 2007
Posts: 300

Rep: 9 Chani.- Unknown
Unique Rep: 9
Trader Rating: 0
Default

thank you but can you do me a favor and test it out on your C compiler for some reason after i enter my Fahrenheit to convert it stops and gives me an error

Code:
#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{

	int f = 0;
	printf("-Fahrenheit to Celsius Converter-n");
	printf("Fahrenheit to convert : ");
	scanf_s("%d",f);
	int c = (5/9)*(f-32);
	printf("%d Degrees in Celsius is %d Degreesn",f,c);
	return 0;
  return 0;
}
heres the fixed code thanks to you
__________________
-- First Build Ever --
аnnїніlатοя

Quote:
Originally Posted by RoadRebel View Post
I'm actually gurious what extreme gaming is? Playing games while kyakiing down whitewater?

System: аnnїніlатοя
CPU
Intel Q6600 B3 2.4Ghz
Motherboard
Asus P5N-E SLI
Memory
OCZ Reaper HPC PC2-6400 (4 x 1GB)
Graphics Card
eVGA 8600GT 256MB
Hard Drive
Western Digital 500GB
Sound Card
Onboard
Power Supply
Thermaltake Toughpower 700W (60A)
Case
Cooler Master 690
CPU cooling
Tuniq Tower 120
GPU cooling
Stock
OS
Windows Vista Ultimate 64-Bit
Chani.- is offline   Reply With Quote
Old 01-09-08   #4 (permalink)
First Time Build
 
BRISKbaby's Avatar
 
intel nvidia

Join Date: Mar 2006
Posts: 582

Rep: 44 BRISKbaby is acknowledged by some
Unique Rep: 41
Folding Team Rank: 158
Trader Rating: 1
Default

You have two "return 0;" lines. Delete one.

EDIT:
I tried to compile it. I don't have stdafx.h header.
__________________

And God said:
∇ • E = ρ / εo; ∇ • B = 0; ∇ x E = - ∂B/∂t; ∇ x B = μoJ + μoεo∂E/∂t;
and there was light .


System: Quantized Quad
CPU
Q6600 (G0)
Motherboard
Asus P5k Deluxe (WiFi/AP)
Memory
2GB Crucial DDR2 1065
Graphics Card
8600GT
Hard Drive
2 X Wd2500KS
Sound Card
XFi - XtremeMusic
Power Supply
PC Power Cooling Silent 750W
Case
Aluminus
CPU cooling
Apogee CPU Block
OS
XP / Vista Ultimate
Monitor
Dell 20" Widescreen

Last edited by BRISKbaby : 01-09-08 at 01:16 AM.
BRISKbaby is offline I fold for Overclock.net   Reply With Quote
Old 01-09-08   #5 (permalink)
First Time Build
 
Chani.-'s Avatar
 
intel nvidia

Join Date: Sep 2007
Posts: 300

Rep: 9 Chani.- Unknown
Unique Rep: 9
Trader Rating: 0
Default

wow i really missed that one but for some reason i still get an error

http://img255.imageshack.us/img255/6199/16445673hr4.jpg heres an image to help you understand where im at
__________________
-- First Build Ever --
аnnїніlатοя

Quote:
Originally Posted by RoadRebel View Post
I'm actually gurious what extreme gaming is? Playing games while kyakiing down whitewater?

System: аnnїніlатοя
CPU
Intel Q6600 B3 2.4Ghz
Motherboard
Asus P5N-E SLI
Memory
OCZ Reaper HPC PC2-6400 (4 x 1GB)
Graphics Card
eVGA 8600GT 256MB
Hard Drive
Western Digital 500GB
Sound Card
Onboard
Power Supply
Thermaltake Toughpower 700W (60A)
Case
Cooler Master 690
CPU cooling
Tuniq Tower 120
GPU cooling
Stock
OS
Windows Vista Ultimate 64-Bit
Chani.- is offline   Reply With Quote
Old 01-09-08   #6 (permalink)
Folding Fanatic
 
FireMarshallBill's Avatar
 
intel nvidia

Join Date: Oct 2007
Location: CR, Iowa
Posts: 350

Rep: 27 FireMarshallBill is acknowledged by some
Unique Rep: 24
Folding Team Rank: 91
Trader Rating: 0
Default

Quote:
Originally Posted by Chani.- View Post
Code:
#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
	printf("-Fahrenheit to Celsius Converter-n");
	printf("Fahrenheit to convert : ");
	int f = scanf_s("%d",f);
	int c = (5/9)*(f-32);
	printf("%d Degrees in Celsius is %d Degreesn",f,c);
	return 0;
  return 0;
}
when i build this in Visual Studios C++ 2008 I get this error


what am i doing wrong?
this line int f = scanf_s("%d",f); uses f in the expression, which has not yet been declared. I have taken some Java, so I'm not 100% sure what exactly everything is, but i believe that is what the problem is
__________________
System: Home PC
CPU
E8400
Motherboard
EVGA 750i FTW
Memory
4X - 1GB OCZ DDR2 800MHz
Graphics Card
EVGA 8800GT SSC Edition
Hard Drive
Multiple Segates 750 GB
Power Supply
NSpire 600W Modular
Case
Rocketfish
GPU cooling
Stock
OS
Windows Vista Buisness 64 bit
Monitor
niko 19" LCD
FireMarshallBill is offline I fold for Overclock.net   Reply With Quote
Old 01-09-08   #7 (permalink)
Every base is base 10
 
rabidgnome229's Avatar
 
intel nvidia

Join Date: Feb 2006
Location: Pittsburgh
Posts: 5,009
Blog Entries: 1

Rep: 566 rabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famous
Unique Rep: 338
FAQs Submitted: 6
Trader Rating: 5
Default

It should read
Code:
scanf_s("%d",&f);
__________________
BIG BROTHER
Apple doesn't love you

IS WATCHING

System: It goes to eleven
CPU
E6300
Motherboard
DS3
Memory
2GB XMS2 DDR2-800
Graphics Card
EVGA 8600GTS
Hard Drive
1.294 TB
Sound Card
Audigy 2 ZS
Power Supply
Corsair 520HX
Case
Lian-Li v1000B Plus
CPU cooling
TTBT
GPU cooling
Thermalright V2
OS
Arch Linux/XP
Monitor
Samsung 226bw
rabidgnome229 is offline Overclocked Account   Reply With Quote
Old 01-09-08   #8 (permalink)
Multi-Quote King
 
The Hundred Gunner's Avatar
 
amd nvidia

Join Date: Jul 2006
Posts: 8,672

Rep: 653 The Hundred Gunner is becoming famousThe Hundred Gunner is becoming famousThe Hundred Gunner is becoming famousThe Hundred Gunner is becoming famousThe Hundred Gunner is becoming famousThe Hundred Gunner is becoming famous
Unique Rep: 371
Folding Team Rank: 1269
Trader Rating: 0
Default

Hmm... I also don't have that .h file. This is the output I get:

untitled.cpp:1:20: error: stdafx.h: No such file or directory
untitled.cpp:4: error: '_TCHAR' has not been declared
untitled.cpp: In function 'int _tmain(int, int**)':
untitled.cpp:8: error: 'printf' was not declared in this scope
untitled.cpp:10: error: 'scanf_s' was not declared in this scope

I have no idea what any of this means; I'm an uber noob at programming

I tried compiling this is g++, btw.

Edit: wouldn't double quotes in:

#include "stdafx.h"

make stdaf.h a string? Shouldn't you use < and >? I don't know at all; I'm just using what I know; I'm probably wrong about that.
__________________
"But you would be amazed by how many people think that the only reason to have a computer is to play games, and that playing games is all that anyone with a computer does." - dangerousHobo

"Linux is everywhere, it is all around us, even now in this very room. You can see it when you look out your window, or you turn on your television. You can feel it when you go to work, when you go to church, when you pay your taxes. " - mbp

"I have used a mac before. And they still don't have right click I mean come on." - aakar

Blah, blah, can't hear you

System: The Shuttle Has Landed
CPU
Athlon 64 3800+ @2.785GHz
Motherboard
Shuttle
Memory
2GB OCZ
Graphics Card
7950GT
Hard Drive
320GB Seagate in Ext. Case
Sound Card
On-board
Power Supply
250W Shuttle "Elanpower"
Case
Shuttle Glamour xPC
CPU cooling
Shuttle "ICE2"
GPU cooling
Stock
OS
Censored to avoid flaming
Monitor
HP M70
The Hundred Gunner is offline I fold for Overclock.net Overclocked Account   Reply With Quote
Old 01-09-08   #9 (permalink)
Every base is base 10
 
rabidgnome229's Avatar
 
intel nvidia

Join Date: Feb 2006
Location: Pittsburgh
Posts: 5,009
Blog Entries: 1

Rep: 566 rabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famous
Unique Rep: 338
FAQs Submitted: 6
Trader Rating: 5
Default

Quote:
Originally Posted by The Hundred Gunner View Post
Hmm... I also don't have that .h file. This is the output I get:

untitled.cpp:1:20: error: stdafx.h: No such file or directory
untitled.cpp:4: error: '_TCHAR' has not been declared
untitled.cpp: In function 'int _tmain(int, int**)':
untitled.cpp:8: error: 'printf' was not declared in this scope
untitled.cpp:10: error: 'scanf_s' was not declared in this scope

I have no idea what any of this means; I'm an uber noob at programming

I tried compiling this is g++, btw.

Edit: wouldn't double quotes in:

#include "stdafx.h"

make stdaf.h a string? Shouldn't you use < and >? I don't know at all; I'm just using what I know; I'm probably wrong about that.
The errors you got are because you don't have the include file, where those functions are declared.

As for the edit, the "#" in front of the include indicates that the line is not C++ code, but info for the compiler. In the C++ standard, include files contained in "" are local files. Files in <> are standard c++ library files
__________________
BIG BROTHER
Apple doesn't love you

IS WATCHING

System: It goes to eleven
CPU
E6300
Motherboard
DS3
Memory
2GB XMS2 DDR2-800
Graphics Card
EVGA 8600GTS
Hard Drive
1.294 TB
Sound Card
Audigy 2 ZS
Power Supply
Corsair 520HX
Case
Lian-Li v1000B Plus
CPU cooling
TTBT
GPU cooling
Thermalright V2
OS
Arch Linux/XP
Monitor
Samsung 226bw
rabidgnome229 is offline Overclocked Account   Reply With Quote
Old 01-09-08   #10 (permalink)
Programmer
 
kdbolt70's Avatar
 
intel ati

Join Date: May 2007
Location: Walled Lake, MI
Posts: 1,119

Rep: 127 kdbolt70 is acknowledged by manykdbolt70 is acknowledged by many
Unique Rep: 92
Folding Team Rank: 284
Trader Rating: 1
Default

do you still need help?
__________________

~M Hail to the Victors M~

System: It's about time!
CPU
Q6600 G0 @3.3Ghz
Motherboard
Gigabyte P35-DS3L
Memory
2Gb Ballistix DDR2 800 @915Mhz
Graphics Card
Sapphire 2900Pro Flashed to XT
Hard Drive
Seagate Barracuda 320Gb
Sound Card
Onboard
Power Supply
Corsair HX 620W
Case
CM 690
CPU cooling
Tuniq Tower 120
GPU cooling
stock
OS
Vista Business and VMWare Ubuntu
Monitor
Acer AL2223W 22"
kdbolt70 is offline I fold for Overclock.net   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:45 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.32746 seconds with 8 queries