array help

I am currently having some issues with this code. It keeps giving me error LNK2019: unresolved external symbol _WinMain@16 referenced in function __tmainCRTStartup
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include <iostream>
#include <string>
#include <fstream>
#include <cmath>
#include <iomanip>


using namespace std;

void main()

{

	cout << "Please enter the filename that wish to open: ";
	string filename;
	cin >> filename;

	ifstream infile;
	infile.open(filename);
	string fname, lname;
	float score;
	int i;
	string myarray[6];
	float myarray1[6];
	for(i=0; i<7; i++);

	{
		infile >> fname >> lname >> score;
		myarray[i] = fname + " " + lname;
		myarray1[i] = score;

	}
 
 
 

	int option;
	while(option < 5)
	{
		cout << "Please choose an option: " << endl;
		cout << "1 Please find the smallest: " << endl;
		cout << "2 Please find the largest: " << endl;
		cout << "3 Please find the total: " << endl;
		cout << "4 Please find the avarage: " << endl;
		cout << "5 Quit" << endl;
		cin >> option;
 

		if(option==1)
		{
			float smallest = myarray1[0];
			int smallest_index;
			for(int i=0; i<6; i++)
			{
				 if(myarray1[i] < smallest)
				{
					smallest = myarray1[i];
					smallest_index;
				}
			}
			cout << myarray[smallest_index] << " ";
			cout << myarray1[smallest_index] << endl;
			}
		else if (option ==2)
		{
			float largest = myarray1[0];
			int largest_index;
			for(int i2=0; i2<6; i2++)
			{	
				if (myarray1[i2] > largest)
				{
					largest = myarray1[i2];
					largest_index = i2;
				}
			}
			cout << myarray[largest_index] << " ";
			cout << myarray1[largest_index] << endl;
		}
		else if(option==3)
		{
			float total = 0;
			for(i=0; i<6; i++)
			{
				total = myarray1[i] + total;
			}
			cout << "The total is: " << total << endl;
		}
		else if (option==4)
		{
			float total, avg;
			total = 0;
			for(i=0; i<6; i++)
			{
				total = myarray1[i] + total;
			}
			avg = total / 6;
			cout << "The avarage is:  " << avg << endl;
		}
		else if(option>=5)
		{
			cout << "Have a nice day!" << endl;
		}

	}

 char ch;
 cin >> ch;
}

I dont get that error you specify?

However, what I did find was this...

Line 37 your using i which is not initialised, and its position doesn't make any sense?

Line 61 you are testing smallest_index, again its not initialised.
Last edited on
Sounds line you selected a WIN32 project rather than a console project.

Ah, good point AbstractionAnon, i just pasted his code into a project I created on auto-pilot, never even gave that a thought :)
Topic archived. No new replies allowed.