Error C2059 and Error 2109

I'm not getting what it's asking for... I'm using visual express for c++
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#include <iostream>
using namespace std;
#include <math.h>
#include <fstream>


void loadData(int dayDate[], double highTemp[],double recordTemp[],
	int recordTempYear[], double relativeHumidity, int&dataCount);
void displayMenu(void);
void displayData(int dayDate[], double highTemp[],double recordTemp[],
	int recordTempYear[], double relativeHumidity, int dataCount);
void displayRecordTempandYear(int dayDate[], double recordTemp[],
	int recordTempYear[], int dataCount);
void calculateRecordTempandYear(int magicDay, int dayDate[], double recordTemp[],
	int recordTempYear[], int dataCount, double &record, int &year);


int main()
{
	double highTemp[100],recordTemp[100], relativeHumidity[100];
	int recordTempYear[100], dayDate[100];
	int Moption,dataCount;

	
	cout<<"Hello! We will be calculating and finding different mathematical"
		" properties for the weather!"<<endl;
	loadData(dayDate[],highTemp[],recordTemp[],recordTempYear[],relativeHumidity[], dataCount);

	do
	{
	displayMenu();
	cout<<"Enter option(1-7): "<<endl;
	cin>>Moption;

			if(Moption == 1)
			{
				displayData(dayDate[],highTemp[],recordTemp[],
					recordTempYear[], relativeHumidity[], dataCount);
			}
			else if (Moption ==2)
			{
				displayRecordTempandYear(dayDate[], recordTemp[],
				recordTempYear[],dataCount);
				cout<<"Test"<<endl;
			}
			else if (Moption ==3)
				cout<<"test"<<endl;
			else if(Moption == 4)
				cout<<"test"<<endl;
			else if(Moption == 5)
				cout<<"test"<<endl;
			else if(Moption == 6)
				cout<<"test"<<endl;
			else if(Moption != 7)
				cout<<endl<<"Please enter a number from 1 to 7"
					<<endl<<endl;

	}
	while(Moption!=7);

	return 0;
}

void loadData(int dayDate[], double highTemp[],double recordTemp[],
	int recordTempYear[], double relativeHumidity, int&dataCount)
{
	fstream infile;
	
	infile.open("c:\\Documents and Settings\\Jake\\Desktop\\arraytest.txt", ios::in);
	dataCount=0;

	do
	{
		infile>>dayDate[dataCount];
		infile>>highTemp[dataCount];
		infile>>recordTemp[dataCount];
		infile>>recordTempYear[dataCount];
		infile>>relativeHumidity[dataCount];
		++dataCount;
	}
	while(dayDate[dataCount-1] != 0);

	infile.close();
	--dataCount;
}

void displayMenu(void)
{
	cout<<"Option 1: Display the data on a table "<<endl;
	cout<<"Option 2: Display record high temperature and the"
		" year it occured"<<endl;
	cout<<"Option 3: Display heat index for each day "<<endl;
	cout<<"Option 4: Display average, maximum, minimum, and range"
		" for one field"<<endl;
	cout<<"Option 5: Display largest difference between two consecutive"
		" values in one field"<<endl;
	cout<<"Option 6: Display chart summarizing the distribution of values"
		" for one field"<<endl;
	cout<<"Option 7: Quit Analyzing this set of data"<<endl;
}

void displayData(int dayDate[], double highTemp[],double recordTemp[],
	int recordTempYear[], double relativeHumidity, int dataCount)
{
	int ix;

	for(ix=0;ix<dataCount;++ix)
	{
		cout<<"Date\tHighTemp\tRecordHigh\tYearOccured\tHumidity"<<endl;
		cout<<dayDate[ix]<<"\t"<<highTemp[ix]<<"\t"<<recordTemp[ix]<<"\t"
			<<recordTempYear[ix]<<"\t"<<relativeHumidity[ix];
	}
}

void displayRecordTempandYear(int dayDate[], double recordTemp[],
	int recordTempYear[], int dataCount)
{
	int magicDay;
	double record;
	int year;
	char condition,anotherDay;

	do
	{
	condition='f';

	cout<<"What day would you like to see the record temperature and"
		" year for?"<<endl;
	cin>>magicDay;

	calculateRecordTempandYear(magicDay, dayDate[],recordTemp[],
		recordTempYear[], dataCount, record, year,condition);

	if(condition=='f')
	{
		cout<<"Sorry, data was not found"<<endl;
	}
	else
	{
		cout<<"Record Temperature: "<<record<<endl;
		cout<<"Year occured: "<<year<<endl;
	}

	cout<<"Another day (y/n)?"<<endl;
	cin>>anotherDay;

	}
	while(anotherDay=='y');
}

void calculateRecordTempandYear(int magicDay, int dayDate[], double recordTemp[],
	int recordTempYear[], int dataCount, double &record, int &year,char condition)
{
	int ix;
	condition='f';

	for(ix=0; ix<dataCount;++ix)
	{
		do
		{
		if(dayDate[ix]==magicDay)
			{
			record=recordTemp[ix];
			year=recordTempYear[ix];
			condition='t';
			}
		}
		while(condition=='f');
	}
}


Errors:

1
2
3
4
5
6
1>c:\documents and settings\jake\my documents\visual studio 2010\projects\program6\program6\source1.cpp(30): error C2059: syntax error : ']'
1>c:\documents and settings\jake\my documents\visual studio 2010\projects\program6\program6\source1.cpp(40): error C2059: syntax error : ']'
1>c:\documents and settings\jake\my documents\visual studio 2010\projects\program6\program6\source1.cpp(45): error C2059: syntax error : ']'
1>c:\documents and settings\jake\my documents\visual studio 2010\projects\program6\program6\source1.cpp(81): error C2109: subscript requires array or pointer type
1>c:\documents and settings\jake\my documents\visual studio 2010\projects\program6\program6\source1.cpp(114): error C2109: subscript requires array or pointer type
1>c:\documents and settings\jake\my documents\visual studio 2010\projects\program6\program6\source1.cpp(134): error C2059: syntax error : ']'


What does it mean by: ']'
When passing an array into a function, you can't write [] after it. Simply write the name of the array.

Here's it at line 27:
loadData(dayDate,highTemp,recordTemp,recordTempYear,relativeHumidity, dataCount);
What about the C2109 Error? For both cases.

EDIT: I figured it out! Thank you so much for your help!
Last edited on
I also noticed that the relativeHumidity is an array, but the function takes it in as a single double.

Anyway, if you were to apply the changes, try to compile, and then show the log again, it may help us get farther. Right now I am incapable of opening up a compiler of my own.


EDIT: Nevermind.
Last edited on
Topic archived. No new replies allowed.