I have used Sleep() before in another program and never had any problems, but this time when I compile it is telling me that Sleep is an undeclared identifier. I #included <ctime> like I did the last time I used it, but it doesn't want to work this time. Hopefully someone can find what I did wrong and let me know.
Thanks
Van
Code:
#include "Date.h"
#include "Classroom.h"
#include <iostream>
#include <ctime>
#include <fstream>
#include <string>
using namespace std;
template <typename T>
void sortArray(T array[], int size);
void printArray(Classroom array[], int size);
void openFile(ifstream& fin);
int fillArray(ifstream& fin, Classroom array[]);
int main()
{
Classroom c_array[20];
ifstream in;
int rooms;
openFile(in);
rooms = fillArray(in, c_array);
printArray(c_array, rooms);
system("pause");
system("cls");
sortArray(c_array, rooms);
printArray(c_array, rooms);
system("pause");
return 0;
}
int fillArray(ifstream& fin, Classroom array[])
{
Classroom temp;
int i=0;
int no_rooms;
fin >> no_rooms;
fin.ignore(200, '\n');
temp.ReadClassroom(fin);
while(!fin.eof() && i <= no_rooms)
{
array[i] = temp;
temp.ReadClassroom(fin);
i++;
}
return no_rooms;
}
void openFile(ifstream& fin)
{
fin.open("a:studentData.txt");
if(fin.fail())
{
cout << "Error opening file";
system("pause");
exit(1);
}
}
void printArray(Classroom array[], int size)
{
cout.setf(ios::fixed);
cout.precision(0);
for(int x=0; x<size; x++)
{
array[x].PrintStats(cout);
Sleep(1000);//<<<<<<<<<<<<<<
}
}
template <typename T>
void sortArray(T array[], int size)
{
int pass, j;
T temp;
int smallIndex;
for(pass = 0; pass < size-1; pass++)
{
smallIndex = pass;
for(j= pass+1; j < size; j++)
{
if(array[j] < array[smallIndex])
smallIndex = j;
}
if(smallIndex != pass)
{
temp = array[pass];
array[pass] = array[smallIndex];
array[smallIndex] = temp;
}
}
}