View previous topic :: View next topic |
Author |
Message |
Mussy69 Grandmaster Cheater
Reputation: 0
Joined: 09 Mar 2007 Posts: 842 Location: Sydney
|
Posted: Wed May 28, 2008 9:28 pm Post subject: [C++] #include Problem |
|
|
Hey Guys,
When i try to compile this code:
Code: | #include <iostream.h>
#include <iomanip.h>
#include <fstreamh.h>
//Functions Prototypes
int displayLine();
float calcSquare(float);
float calcHalf(float);
int main()
{
//Declare And Initialize Variables
float numberInput = 0.0;
float numberSquared = 0.0;
float numberHalved = 0.0;
//Accept Input From User
cout << "Enter A Number: ";
cin >> numberInput;
//Call Functions To Do Calculations
numberSquared = calcSquare(numberInput);
numberHalved = calcHalf(numberInput);
ofstream outFile;
outFile.open("Beginner Program1.dat");
//Display Output Items
displayLine();
cout << setprecision(2) << setiosflags(ios::fixed|ios::showpoint);
cout << "Result of Calculations" << endl;
outFile << "Result of Calculations" << endl;
cout << "Square of Number: " << numberSquared << endl;
outFile << "Square of Number: " << numberSquared << endl;
cout << "Half of Number: " << numberHalved << endl;
outFile << "Half of Number: " << numberHalved << endl;
displayLine();
}
int displayLine();
{
cout << "----------------------------------------"
} | It returns an error because there is no such file or directory for the .h in the includes, but when i take out the .h everything they are meant to support is now undeclared, so is there like a code for these includes that i might need?
Thanks Alot
_________________
|
|
Back to top |
|
 |
HalfPrime Grandmaster Cheater
Reputation: 0
Joined: 12 Mar 2008 Posts: 532 Location: Right there...On your monitor
|
Posted: Wed May 28, 2008 9:34 pm Post subject: |
|
|
If there is no such file or directory, then you're missing those files. Google, download, put them in your includ directory.
_________________
|
|
Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Wed May 28, 2008 9:39 pm Post subject: |
|
|
Did you download the sdk?
_________________
8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
Back to top |
|
 |
Heartless I post too much
Reputation: 0
Joined: 03 Dec 2006 Posts: 2436
|
Posted: Wed May 28, 2008 9:39 pm Post subject: |
|
|
Code: | //Here are some fixes
#include<iostream>
#include<fstream.h>
using namespace std; |
_________________
What dosen't kill you, usually does the second time. |
|
Back to top |
|
 |
Mussy69 Grandmaster Cheater
Reputation: 0
Joined: 09 Mar 2007 Posts: 842 Location: Sydney
|
Posted: Wed May 28, 2008 9:44 pm Post subject: |
|
|
I was told by wiccaan using namespace std; is a waste instead use std:: infront of cin and cout
@ Half Prime, Would i have to do this every time i code?
_________________
|
|
Back to top |
|
 |
HalfPrime Grandmaster Cheater
Reputation: 0
Joined: 12 Mar 2008 Posts: 532 Location: Right there...On your monitor
|
Posted: Wed May 28, 2008 9:52 pm Post subject: |
|
|
No, you wouldn't. These are files used by the compiler that it has to have. You just have to put them in the include directory of your compiler, then you're set.
_________________
|
|
Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Wed May 28, 2008 10:11 pm Post subject: |
|
|
Mussy69 wrote: | I was told by wiccaan using namespace std; is a waste instead use std:: infront of cin and cout
@ Half Prime, Would i have to do this every time i code? |
It's only a waste if you're only using cin and cout. I put it anyway, but you don't need to use the whole namespace when your only using two functions in the namespace you may as well just put std::cout std::cin.
_________________
8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
Back to top |
|
 |
Mussy69 Grandmaster Cheater
Reputation: 0
Joined: 09 Mar 2007 Posts: 842 Location: Sydney
|
Posted: Wed May 28, 2008 11:03 pm Post subject: |
|
|
So could you help me with these #includes? cuz i got no idea where to download it from or where to put it when i do download it
_________________
|
|
Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Thu May 29, 2008 4:48 am Post subject: |
|
|
Download the Microsoft SDK from the other thread wiccaan posted it in. Then go to the options and find VC++ Directories or something like that and add the *SDK Location*\Include Folder to the list of includes and in the *SDK Location*\Lib to the list of lib's and finally add *SDK Location*\bin to the list of Executable files
_________________
|
|
Back to top |
|
 |
Mussy69 Grandmaster Cheater
Reputation: 0
Joined: 09 Mar 2007 Posts: 842 Location: Sydney
|
Posted: Sat May 31, 2008 2:00 am Post subject: |
|
|
Uhh it didnt work because like all the others have $(something/something)path and i dont no what it is for this one so could someone help me with that?
_________________
|
|
Back to top |
|
 |
HalfPrime Grandmaster Cheater
Reputation: 0
Joined: 12 Mar 2008 Posts: 532 Location: Right there...On your monitor
|
Posted: Sat May 31, 2008 10:14 am Post subject: |
|
|
I didn't understand all that, but I tihnk you don't know where the VC lib/include directories are? Go into options, it should be in there. Other than that, go to the VC directory and there should be lib and include directories.
_________________
|
|
Back to top |
|
 |
Mussy69 Grandmaster Cheater
Reputation: 0
Joined: 09 Mar 2007 Posts: 842 Location: Sydney
|
Posted: Sun Jun 01, 2008 11:31 pm Post subject: |
|
|
no my options is missing it but in the vc directory every other directory starts like $(whatever/whatever)directory, i dont no what the lib/include directory are if it has to include the $(whatever/whatever)directory
_________________
|
|
Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Mon Jun 02, 2008 12:29 am Post subject: |
|
|
Examples of using SDKs. Do that for the normal SDK. I used the DirectX SDK as an example.
_________________
8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
Back to top |
|
 |
|