1st your English is bad.
2nd do you know what ifstream does ? As i cant see where you add the OFSTREAM !!
3rd cout ? are you serious ? man you have to choose between the <fstream> and <iostream>
4th *heap, is a pointer. do you know what tht is ?
PS: go check the cplusplus tutorial and rewrite your code.
ok... means what ? all i want is to read the numbers from a file (i don't quite understand why do i need a ofstream for?)... and cout into the compiler and view the results, it doesn't work in this way?
nope !
if you want read from file than you must Print the result TO FILE too.
tht is done by
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <fstream>
usingnamespace std;
int main()
{
int a,b,c; // variables
ifstream in("yourfile.in"); // here you declare the file from where the variables will be read
ofstream out("yourfile.out"); // here you declare the file in which you print the result
in >> a; // this is the "cin" in the <fstream>
in >> b; // this is the "cin" in the <fstream>
c = a+b;
out << c; // this is the "cout" int the <fstream>
in.close(); // you close the reading file
out.close(); // you close the printing file
return 0;
}
#include <iostream> // for cout
#include <fstream> // to be able to read from file
usingnamespace std;
int main()
{
int a,b,c; // variables
ifstream in("yourfile.in"); // here you declare the file from where the variables will be read
in >> a; // this is the "cin" in the <fstream>
in >> b; // this is the "cin" in the <fstream>
c = a+b;
cout << c;
in.close(); // you close the reading file
return 0;
}
// dont forget to type:
ifstream in("GiveAnameToTheFile.in");
//THE .in !! and NOT .txt !!!
// and also dont forget to do:
in.close();
// at the end of file !
void heapSort(int arraylist[], int size)
{
for (int i = size; i>1; i--)
{
swapNode(arraylist, 1, i); // swap first and last node
siftDown(arraylist, 1, i-1); // siftdown tree
}
}
seems to be ok, just try what i said. 1st change the input.txt into input.in and add infile.close() at end;