Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » What's wrong in this C++ code
Closed Thread
Old 10-12-2007, 11:38 PM   #1 (permalink)
 
Super Techie

Join Date: Sep 2006

Location: Altoona, PA

Posts: 250

Mike9182 is on a distinguished road

Send a message via AIM to Mike9182
Default What's wrong in this C++ code

///
/// Program to convert temperature from Celsius degree
/// units into Fahrenheit degree units:
/// Fahrenheit = Celsius * (212 - 32)/100 + 32
///
#include <iostream.h>
#include <stdio.h>

int main(int nNumberofArgs, char* pszArgs[])
{
/// enter the temperature in Celsius
int celsius;
cout << "Enter the temperature in Celsius:";
cin >> celsius ;

/// calculate conversion factor for Celsius:";
/// to Fahrenheit
int factor;
factor = 212 - 32;

/// user conversion factor to convert Celsius
/// into Fahrenheit values
int fahrenheit;
fahrenheit = factor * celsius/100 + 32;

/// output the results
cout << "Fahrenheit value is:";
cout << fahrenheit;

return 0;
}


1>------ Build started: Project: Conversion actual, Configuration: Debug Win32 ------
1>Compiling...
1>conversion.cpp
1>d:\documents and settings\mike\my documents\visual studio 2005\projects\conversion actual\conversion actual\conversion.cpp(6) : fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory
1>Build log was saved at "file://d:\Documents and Settings\Mike\My Documents\Visual Studio 2005\Projects\Conversion actual\Conversion actual\Debug\BuildLog.htm"
1>Conversion actual - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I have the include files in the header files folder in the project organizer, so what do I need to change?
__________________

My Comp:
Antec 900
Gigabyte DS3
EVGA 8800GTS (G92)
Antec TruPower 650 watt psu
Core 2 Duo E6700 @ 3.3Ghz
G.Skill 4GB DDR2-800
2 x Seagate Barracuda 250GB HDD in RAID 0
1 x Seagate Barracuda 500GB HDD
ACER 19" 5ms monitor
ZALMAN CNPS9500 cpu fan/heatsink
Mike9182 is offline  
Old 10-13-2007, 03:33 AM   #2 (permalink)
 
Software Developer

Join Date: Mar 2006

Location: Columbus, OH

Posts: 569

jaeusm is on a distinguished road

Default Re: What's wrong in this C++ code

Remove the '.h' extension on the end of each include. Also, change stdio to cstdio. It should look like this:
Code:
#include <iostream>
#include <cstdio>
For future reference, use code tags when posting code in this forum.
jaeusm is offline  
Old 10-13-2007, 09:46 PM   #3 (permalink)
 
Super Techie

Join Date: Sep 2006

Location: Altoona, PA

Posts: 250

Mike9182 is on a distinguished road

Send a message via AIM to Mike9182
Default Re: What's wrong in this C++ code

ok, thanks
__________________

My Comp:
Antec 900
Gigabyte DS3
EVGA 8800GTS (G92)
Antec TruPower 650 watt psu
Core 2 Duo E6700 @ 3.3Ghz
G.Skill 4GB DDR2-800
2 x Seagate Barracuda 250GB HDD in RAID 0
1 x Seagate Barracuda 500GB HDD
ACER 19" 5ms monitor
ZALMAN CNPS9500 cpu fan/heatsink
Mike9182 is offline  
Old 10-14-2007, 08:35 AM   #4 (permalink)
jay_bo's Avatar
 
Ultra Techie

Join Date: Jul 2006

Posts: 898

jay_bo is on a distinguished road

Default Re: What's wrong in this C++ code

no i have ran this program before and it should be
#include <iostream.h>
#include <conio.h>

worked for me anyway

set it out likle this.

#include <iostream.h>
#include <conio.h>

main ()
{
clrscr();

your code

getch();
return 0;
}

i will try it myslef if i get time
__________________
jay_bo is offline  
Old 10-14-2007, 08:40 AM   #5 (permalink)
jay_bo's Avatar
 
Ultra Techie

Join Date: Jul 2006

Posts: 898

jay_bo is on a distinguished road

Default Re: What's wrong in this C++ code

///
/// Program to convert temperature from Celsius degree
/// units into Fahrenheit degree units:
/// Fahrenheit = Celsius * (212 - 32)/100 + 32
///
#include <iostream.h>
#include <conio.h>

int main(int nNumberofArgs, char* pszArgs[])
{
clrscr();
/// enter the temperature in Celsius
int celsius;
cout << "Enter the temperature in Celsius:";
cin >> celsius ;

/// calculate conversion factor for Celsius:";
/// to Fahrenheit
int factor;
factor = 212 - 32;

/// user conversion factor to convert Celsius
/// into Fahrenheit values
int fahrenheit;
fahrenheit = factor * celsius/100 + 32;

/// output the results
cout << "Fahrenheit value is:";
cout << fahrenheit;
getch();
return 0;
}


works for me in borland, i have done the fahrenheit program but i used varribles in mine like float, if you know what i mean
__________________
jay_bo is offline  
Old 10-15-2007, 12:12 AM   #6 (permalink)
 
Software Developer

Join Date: Mar 2006

Location: Columbus, OH

Posts: 569

jaeusm is on a distinguished road

Default Re: What's wrong in this C++ code

Quote:
no i have ran this program before and it should be
#include <iostream.h>
#include <conio.h>
The file 'conio.h' has nothing to do with it. The compiler output states exactly what the problem was: "fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory". Also, the output states that he was using Visual Studio 2005, not Borland.
jaeusm is offline  
Old 10-15-2007, 05:25 PM   #7 (permalink)
forrestcupp's Avatar
 
Ultra Techie

Join Date: Feb 2007

Posts: 588

forrestcupp is on a distinguished road

Default Re: What's wrong in this C++ code

Just do what jaeusm said and remove the .h from your includes. And you should be able to use stdio and be alright.

Unless you are going to be adding code to this program, you don't really need any arguments in your main function.
forrestcupp is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Code 1000008e Nitrocrusher Hardware Troubleshooting 0 09-24-2007 03:04 PM
Someone take a look at my Java code PnkFloyd27 Programming Discussions 4 06-21-2007 08:11 PM
windows media error code on vista.... topps999 Windows Operating Systems and Software 1 05-28-2007 09:23 PM
NEED help with a Javascript code...(mouseover and stuff) Quintox Web Graphics, Design, Digital Images 7 05-02-2007 06:41 PM
JavaScript Botnet Code Leaked To Internet Osiris Virus - Spyware Protection / Detection 0 04-02-2007 09:05 PM