So this is my program currently. It not finished but I figured out I would put it up here to see if I could get some help. I used for loops to get the general idea but I really need the program to pull the first value from each array and display the messages and then x amount of time later pull the second value and display those messages until it has pulled all six values from the vector.
I'm printing out the vectors just to see the values while i'm testing the program but eventually i will get rid of that part.
#include <iostream>
#include <vector>
#include <fstream>
#include <string>
#include <ctime>
usingnamespace std;
int main(void)
{
vector<double> temp(0);
double temperature;
int i;
int j;
int k;
int l;
int m;
int n;
int p;
char exitProgram;
ifstream ipFile1; /* Defining an input file */
ipFile1.open ("temperatures.txt"); /* Opening the file */
if (ipFile1.is_open()) /* Ensuring that the file is open */
{
/* Reading the contents of the file */
while ( ipFile1 >> temperature ) /* Reads the string from the input file into the string variable tempString */
{
temp.push_back(temperature);
}
cout << endl;
ipFile1.close(); /* Closing the file since we are done */
}
for(i=0;i<temp.size();i++)
{
cout << temp.at(i) << endl;
} /* End for loop */
vector<double> HCNppm(0);
double HCN;
ifstream ipFile2; /* Defining an input file */
ipFile2.open ("HCNppm.txt"); /* Opening the file */
if (ipFile2.is_open()) /* Ensuring that the file is open */
{
/* Reading the contents of the file */
while ( ipFile2 >> HCN ) /* Reads the string from the input file into the string variable tempString */
{
HCNppm.push_back(HCN);
}
cout << endl;
ipFile2.close(); /* Closing the file since we are done */
}
for(j=0;j<HCNppm.size();j++)
{
cout << HCNppm.at(j) << endl;
} /* End for loop */
vector<double> COppm(0);
double CO;
ifstream ipFile3; /* Defining an input file */
ipFile3.open ("COppm.txt"); /* Opening the file */
if (ipFile3.is_open()) /* Ensuring that the file is open */
{
while ( ipFile3 >> CO ) /* Reads the string from the input file into the string variable tempString */
{
// cout << temperature << " ";
COppm.push_back(CO);
}
cout << endl;
ipFile3.close(); /* Closing the file since we are done */
}
for(k=0;k<COppm.size();k++)
{
cout << COppm.at(k) << endl;
} /* End for loop */
vector<double> COinMask(0);
double COin;
ifstream ipFile4; /* Defining an input file */
ipFile4.open ("COinMask.txt"); /* Opening the file */
if (ipFile4.is_open()) /* Ensuring that the file is open */
{
while ( ipFile4 >> COin ) /* Reads the string from the input file into the string variable tempString */
{
// cout << temperature << " ";
COinMask.push_back(COin);
}
cout << endl;
ipFile4.close(); /* Closing the file since we are done */
}
for(l=0;l<COinMask.size();l++)
{
cout << COinMask.at(l) << endl;
} /* End for loop */
vector<double> HCNinMask(0);
double HCNin;
ifstream ipFile5; /* Defining an input file */
ipFile5.open ("HCNinMask.txt"); /* Opening the file */
if (ipFile5.is_open()) /* Ensuring that the file is open */
{
/* Reading the contents of the file */
while ( ipFile5 >> HCNin ) /* Reads the string from the input file into the string variable tempString */
{
HCNinMask.push_back(HCNin);
}
cout << endl;
ipFile5.close(); /* Closing the file since we are done */
}
for(m=0;m<HCNinMask.size();m++)
{
cout << HCNinMask.at(m) << endl;
} /* End for loop */
vector<double> internaltemperature(0);
double intemp;
ifstream ipFile6; /* Defining an input file */
ipFile6.open ("internaltemp.txt"); /* Opening the file */
if (ipFile6.is_open()) /* Ensuring that the file is open */
{
/* Reading the contents of the file */
while ( ipFile6 >> intemp ) /* Reads the string from the input file into the string variable tempString */
{
internaltemperature.push_back(intemp);
}
cout << endl;
ipFile6.close(); /* Closing the file since we are done */
}
for(n=0;n<internaltemperature.size();n++)
{
cout << internaltemperature.at(n) << endl;
} /* End for loop */
cout << "Conditions from the sensors placed on firefighters gear will be read in every 10 seconds,";
cout << endl << "along with a message describing the meaning of those readings.";
cout << endl;
cout << "To exit program press 'x'";
cin >> exitProgram;
i=0;
j=0;
k=0;
l=0;
m=0;
n=0;
for (i=0 ; i<=6 ; i++)
{
if (temp.at(i)<= 200)
{
cout << "Fire still in growth stage producing large amounts of smoke produced";
cout << endl << "No major issues" << endl;
}
elseif (temp.at(i)>200 && temp.at(i)<400)
{
cout << "Rising temperatures, getting closer to the seed of the fire";
cout << endl << "Conditons are getting increasing more dangerous.";
cout << "Move foreward to fire attack or begine to plan an evacuation ";
cout << "for the firefighters working inside" << endl;
}
elseif (temp.at(i)>=400 && temp.at(i)<850)
{
cout << "WARNING: extremely high temperatures" << endl;
cout << "Imediately get water onto the fire or make way out of the building";
cout << endl << "Approaching flashover conditions" << endl;
}
else
{
cout << "WARNING!! WARNING!!" << endl;
cout << "Flashover conditions, evcuate the building, " << endl;
cout << "move to exterior attack." << endl ;
}
cout << endl;
} //End for (i)
for (j=0 ; j<=6 ; j++)
{
if (HCNppm.at(j)<=100)
{
cout << "Low levels of HCN in the enviornemt, no real issue" << endl;
}
elseif (HCNppm.at(j)>100 && HCNppm.at(j)<=200)
{
cout << "Increased HCN levels, direct exposeure will result to death in 10 minutes";
cout << endl;
}
elseif (HCNppm.at(j)>200 && HCNppm.at(j)<=1000)
{
cout << "WARNING: high values of HCN will cause death after 5 min of exposure";
cout << endl << "Monitor levels inside of mask" << endl;
}
else
{
cout << "WARNING!! WARNING!!" << endl;
cout << "Extremely high levels of HCN, 1 min of direct exposure will result in death";
cout << endl;
}
} // end for (j)
for (k=0 ; k<=6 ; j++)
{
} // end for (k)
for (l=0 ; l<=6 ; l++)
{
} //end for (l)
for (m=0 ; m<=6 ; m++)
{
} // end for (m)
for (n=0 ; n<=6 ; n++)
{
} // end for (n)
return 0;
} /* End main */
I'm a little confused. Where exactly would I put this in my code. Would i only have to do it once or would i have to do it to replace every for loop that i already have in the code.
So I tried to run this code to see how it work and I got multiple errors saying that the i need the 2011 version of c++ and that the compiler that i"m using does not support that. Is there any other way to do it. Or what do i need to do to get it to work with the compiler that im using.
And i'm also getting runtime error after I run the whole program. It will stop after going through the very first for loop for the temp vector and i'm not sure why it wont run through all of the for loops.
Alright so I updated the compiler and can now do the c++11. But when I try to compile the small program that you sent just to see how it works im still getting errors that im not sure how to fix before i try to change it to work with my program
I just tried it with just the Sleep function and the delay worked but I need it to pull the first value form each vector after 10 seconds and the the second value from the vector after another 20 seconds