Variable not initialized

When I try to run my program this pops up: Run-Time Check Failure #3 - The variable 'quit' is being used without being initialized. I thought I initialized quit so I don't know how to fix this

//Name: Amanda Glavin
//Assignment: Converting Miles to Kilometeres
//Date: July 6, 2015
//Lab: Midterm

#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;

ofstream ofs ("glavin_midterm.txt");

string hdr = "Amanda Glavin ENGR CIS 2485 Converting Miles to Kilometers";
string fot = "-----------------End of Data-----------------";
string eof = "EOF MESSAGE - Amanda Glavin, July 6 2015, Midterm, All Done";
string fin = "Following Instructions";
string twt = "20%";
string ten = "10%";
string hun = "100%";
string scr = "your score is ----------";
string pts = "100";
string dit = "Does It Run";
string doc = "Correct Doc's";
string frm = "Format";
string str = "Structure";
string nam = "Correct files/names";
string tot = "Total Scores";
string pon = "Midterm Points";

void header()
{
ofs << endl;
ofs << hdr << endl;
ofs << endl;
}

void footer()
{
ofs << endl;
ofs << fot << endl;
ofs << endl;
}

void grading()
{
ofs << endl;
ofs << fin << setw(8) << twt << setw(25) << scr << endl;
ofs << dit << setw(19) << twt << setw(25) << scr << endl;
ofs << doc << setw(17) << ten << setw(25) << scr << endl;
ofs << frm << setw(24) << ten << setw(25) << scr << endl;
ofs << str << setw(21) << twt << setw(25) << scr << endl;
ofs << nam << setw(11) << twt << setw(25) << scr << endl;
ofs << tot << setw(18) << hun << setw(25) << scr << endl;
ofs << pon << setw(18) << pts << setw(26) << scr << endl;
ofs << endl;
}

void eofmsg()
{
ofs << endl;
ofs << eof << endl;
ofs << endl;
}

int main()
{
header();

int makeMilesKmTable;
double miles, kilometers;
int quit;

while (quit != 1)
{
// Display the menu.
cout << "1. Run one conversion of miles to kilometers." << endl;
cout << "2. Run many conversions of miles to kilometers." << endl;
cout << "3. Quit." << endl;
cout << endl;

// Promt the user for a selection
cout << "Enter your selection. " << endl;
cin >> makeMilesKmTable;

while (makeMilesKmTable < 1 || makeMilesKmTable > 4)
{
cout << "That is an invalid selection. " << endl;
cout << "Enter 1, 2, or 3." << endl;
cin >> makeMilesKmTable;
}

switch (makeMilesKmTable)
{
case 1:
cout << "Enter the number of miles. " << endl;
cin >> miles;
kilometers = miles * 1.61;
ofs << miles << "=" << kilometers << endl;
break;

case 2:
{
int counter = 0;
while(counter < 301)
cout << "Enter the number of miles." << endl;
cin >> miles;
kilometers = miles * 1.61;
ofs << miles << "=" << kilometers << endl;
counter++;
break;
}

case 3:
quit = 1;
break;
}
}
footer();

grading();

eofmsg();

ofs.close();
return 0;
}
1
2
3
    int quit; //Declaration

    while (quit != 1) { //First use 
So, where quit is initialized here
try int quit = 0;???? if its saying its not initialized then initialize it. maybe?
Topic archived. No new replies allowed.