Need Help output File not working:(

+1 joy Dutches of Dorkness · September 15, 2014
#include<iostream>
#include<fstream>

using namespace std;
//create a template
template<class typex>
void SelSort(typex data[], int length)
{
int  minIndx;
typex temp;
for (int passCount = 0; passCount < length - 1; passCount++)
{
minIndx = passCount;

for (int searchIndx = passCount + 1; searchIndx < length; searchIndx++)
if (data[searchIndx] < data[minIndx])
minIndx = searchIndx;

temp = data[minIndx];
data[minIndx] = data[passCount];
data[passCount] = temp;
}
}


int main()
{
ifstream intFile;
ofstream outFile;
intFile.open("E:\\IntFile.txt");
outFile.open("E:\\IntFileout.txt");
int index;
int intarray[100];
int count = 0;

while (intFile)
{

count++;
}
outFile <<count << " " << endl;
};


********************************************************************************************************

I get no errors when running this but my out put file displays a "0"
could you help me figure this out ..I am about to throw this laptop.
Thanks in advance

Post a Reply

Replies

Oldest  Newest  Rating
+2 Franz Schmidt · September 15, 2014
I think you want to write something in your output file but look at your while loop:

while (intFile)
{
count++;
}
outFile << count << " " << endl;

You will never write anything in your outFile cause you count till worlds end XD
  • 1

C++

124,604 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator