void function not calling
Nov 2, 2013 at 2:24am UTC
I've been trying to get my program to call void functions with an if statement, but when i run my program and try to call one of the functions "worst case, best case, or random case" it dosent get called. It just prompts the original menu. thnx in advance.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
#include<iostream>
#include<fstream>
using namespace std;
void bubbleSort();
void selectionSort();
void insertionSort();
void worstcase();
void randomdata();
void bestcase();
int main()
{
char option;
while (option != '4' )
{
cout << "SORTING EXPERIMENTS\n____________________" << endl;
cout << "\n 1.Data Management\n 2.Test Run\n 3.Statistics\n 4.Quit" << endl;
cout << "\n Select an Option: " ;
cin >> option;
cout << endl;
if (option == '4' ) break ;
if (option == '1' )
{
cout << "DATA MANAGEMENT\n_______________" << endl;
cout << "\n 1.Create New Data File\n 2.Add Data to File\n 3.Delete Data from File"
<< endl;
cout << "\n Select an Option: " ;
cin >> option;
cout << endl;
}
if (option == '2' )
{
cout << "\n Which type of data file?\n \n 1.RandomData \n 2.WorstCase \n 3.Best Case " << endl;
cin >> option;
cout << endl;
if (option == '1' )
{
void randomdata();
}
else if (option == '2' )
{
void worstcase();
}
else if (option == '3' )
{
void bestcase();
}
}
}
return 0;
}
void randomdata()
{
short dat;
ofstream datafile ("RandomData.txt" , ios::app);
cout << "\n Enter New Data: " ;
cin >> dat;
datafile << dat << endl;
datafile.close();
cout << "\n New data entered.\n " ;
}
void worstcase()
{
short dat;
ofstream datafile ("RandomData.txt" , ios::app);
cout << "\n Enter New Data: " ;
cin >> dat;
datafile << dat << endl;
datafile.close();
cout << "\n New data entered.\n " ;
}
void bestcase()
{
short dat;
ofstream datafile ("BestCase.txt" , ios::app);
cout << "\n Enter New Data: " ;
cin >> dat;
datafile << dat << endl;
datafile.close();
cout << "\n New data entered.\n " ;
}
Nov 2, 2013 at 2:32am UTC
Lol i realized the calls had void infront
Topic archived. No new replies allowed.