Function Errors In Calendar Program

Hey I'm new to C++ and I'm having an issue with the current program I am writing. I am getting only getting one error. Can someone tell me what I am doing wrong. I have been trying to fix it all night. I am not allowed to use global variables which has made it much more difficult on me. I know I need to declare it the three somewhere but even when I declare the 3 arguments in the spacer or monthNums functions, I am still getting the same error. Thanks in advance.

Here is the error:

error C2660: 'monthNums' : function does not take 3 arguments - 212.

Here is my full code:

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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
// This program will be used to print a calendar for any givn year and the day of the week

#include <iostream>
#include <iomanip>

void printCal(int year, int start); 

using namespace std;

//Function 1
//Prints Calendar
void printCal(int year, int start, int monthDays, int spacerDays, int prevSpacer, int dayCount = 1, int colCount = 0)
{
	void monthNames(int count);
	void dayNames();
	void monthNums(int count, int& monthDays, int& spacerDays);
	void spacer(int start, int& colCount, int count, int& prevSpacer);
	void wrapper(int dayCount, int monthDays);

	int count;
	for (count = 1; count <= 12; count++)
	{
		monthNames(count); 
		dayNames(); 
		monthNums(count, monthDays, spacerDays); 
		spacer(start, colCount, count, prevSpacer); 
		wrapper(dayCount, monthDays); 
	}
}

//Function 2
//Makes The Lines Return
void wrapper(int dayCount, int monthDays, int colCount)
{
	while (dayCount <= monthDays) 
	{ 
		if (colCount == 7)  
		{
			cout << endl;
			colCount = 0;
		}
		cout << setw(3); 
		cout << dayCount; 
		colCount++; 
		dayCount++;
	}
	colCount = 0;
	cout << endl << endl; 
}
 
//Function 3
//Checks For Leap Year
bool leapYear(int year) 
{
	if (year % 400 == 0)
	{ 
		return true;
	}
	if (year % 100 == 0)
	{
		return false;
	}
	if (year % 4 == 0)
	{
		return true;
	}
	return false; 
}
 
//Function 4
//Previous And Current Days In Each Month
void monthNums(int& count, int& monthDays, int& spacerDays, int year, int monthCount)
{
	switch (count)
	{
	case 1:
		monthDays = 31;
		break;
	case 2: 
		if(leapYear(year))
			//Check For Leap Year
			monthDays = 29;
		if(!leapYear(year))
			monthDays = 28;
		spacerDays = 31; 
		break;
	case 3: 
		monthDays = 31;
		if(leapYear(year)) 
			//Check For Leap Year
			spacerDays = 29;
		if(!leapYear(year))
			spacerDays = 28;
		break;
	case 4: 
		monthDays = 30;
		spacerDays = 31;
		break;
	case 5: 
		monthDays = 31;
		spacerDays = 30;
		break;
	case 6: 
		monthDays = 30;
		spacerDays = 31;
		break;
	case 7: 
		monthDays = 31;
		spacerDays = 30;
		break;
	case 8: 
		monthDays = 31;
		spacerDays = 31;
		break;
	case 9: 
		monthDays = 30;
		spacerDays = 31;
		break;
	case 10: 
		monthDays = 31;
		spacerDays = 30;
		break;
	case 11: 
		monthDays = 30;
		spacerDays = 31;
		break;
	case 12: 
		monthDays = 31;
		spacerDays = 30;
		break;
	}
}

//Function 5
//Prints Out All Month Names
void monthNames(int count, int year) 
{
	switch (count)
	{
	case 1:
		cout << "      January " << year << endl;
		break;
	case 2:
		cout << "      February " << year << endl;
		break;
	case 3:
		cout << "      March " << year << endl;
		break;
	case 4:
		cout << "      April " << year << endl;
		break;
	case 5:
		cout << "      May " << year << endl;
		break;
	case 6:
		cout << "      June " << year << endl;
		break;
	case 7:
		cout << "      July " << year << endl;
		break;
	case 8:
		cout << "      August " << year << endl;
		break;
	case 9:
		cout << "      September " << year << endl;
		break;
	case 10:
		cout << "      October " << year << endl;
		break;
	case 11:
		cout << "      November " << year << endl;
		break;
	case 12:
		cout << "      December " << year << endl;
		break;
	}
}

//Function 6
//Prints Days And Indents Them Accordingly
void dayNames()
{
	cout << " --------------------" << endl;
	cout << "  S  M  T  W  T  F  S" << endl;
}

//Function 7
//This Prints The Spaces Between Days and Months
void spacer(int start, int count, int& colCount, int& prevSpacer, int& monthDays, int& monthCount, int& spacerDays, int& year)
{
		if (count == 1)
	{
		int loopCount;
		for (loopCount = 0; loopCount < start; loopCount++)
		{
			cout << "   ";
			prevSpacer++;
		}
		colCount =+ start;
	}
	else if (count != 1)
	{
		int otherSpacer;
		int loopCount;
		int monthCount = count;
		
		monthNums(monthCount, monthDays, spacerDays);
		//Adds Number Of Spaces And Divides By 7
		otherSpacer = (prevSpacer + spacerDays) % 7;
		prevSpacer = 0;
		for (loopCount = 0; loopCount < otherSpacer; loopCount++)
		{
			cout << "   "; 
			prevSpacer++; 
			colCount =+ otherSpacer;
		}
	}
}

//Main Function
int main()
{
	int year;
	int start;

	cout << "Please Enter Year To View The Calender: ";
	cin >> year;

	while(year <= 0)
	{
		cout<<"Please Enter A Valid Year (Larger Than 0): ";
		cin >> year;
	}

	cout << endl << "0 - Sunday" << endl << "1 - Monday" << endl << "2 - Tuesday" << endl << "3 - Wednesday" << endl << "4 - Thursday" << endl << "5 - Friday" << endl << "6 - Saturday" << endl << endl;
	cout << "Please Enter The Day Of The Week January 1st Falls On (See Above): ";
	cin >> start;	
	cout << endl << endl << endl;

	//Check To Make Sure User Entered A Correct Day
	while ((start < 0) && (start > 6))
	{
		cout << endl << endl << endl;
		cout << "You Entered An Incorrect Day. Please Enter An Integer Between 0-6.";
		cin>>start;
	}

	printCal(year, start); // Calls The Function So That It Prints The Calender
	
	cout << endl;
	system("pause");
	return(0);
}  
Last edited on
You have defined monthNums to take 5 arguments but you only pass it 3.
Peter,
I have tried that as well but it throws even more errors that I don't even know what they mean.

Here is what I'm doing:

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
//Function 4
//Previous And Current Days In Each Month
void monthNums(int& count, int& monthDays, int& spacerDays, int year, int monthCount)
{
	switch (count)
	{
	case 1:
		monthDays = 31;
		break;
	case 2: 
		if(leapYear(year))
			//Check For Leap Year
			monthDays = 29;
		if(!leapYear(year))
			monthDays = 28;
		spacerDays = 31; 
		break;
	case 3: 
		monthDays = 31;
		if(leapYear(year)) 
			//Check For Leap Year
			spacerDays = 29;
		if(!leapYear(year))
			spacerDays = 28;
		break;
	case 4: 
		monthDays = 30;
		spacerDays = 31;
		break;
	case 5: 
		monthDays = 31;
		spacerDays = 30;
		break;
	case 6: 
		monthDays = 30;
		spacerDays = 31;
		break;
	case 7: 
		monthDays = 31;
		spacerDays = 30;
		break;
	case 8: 
		monthDays = 31;
		spacerDays = 31;
		break;
	case 9: 
		monthDays = 30;
		spacerDays = 31;
		break;
	case 10: 
		monthDays = 31;
		spacerDays = 30;
		break;
	case 11: 
		monthDays = 30;
		spacerDays = 31;
		break;
	case 12: 
		monthDays = 31;
		spacerDays = 30;
		break;
	}
}

//Function 7
//This Prints The Spaces Between Days and Months
void spacer(int start, int count, int& colCount, int& prevSpacer, int& monthDays, int& monthCount, int& spacerDays, int& year)
{
		if (count == 1)
	{
		int loopCount;
		for (loopCount = 0; loopCount < start; loopCount++)
		{
			cout << "   ";
			prevSpacer++;
		}
		colCount =+ start;
	}
	else if (count != 1)
	{
		int otherSpacer;
		int loopCount;
		int monthCount = count;
		
		monthNums(count, monthDays,spacerDays, year, monthCount);
		//Adds Number Of Spaces And Divides By 7
		otherSpacer = (prevSpacer + spacerDays) % 7;
		prevSpacer = 0;
		for (loopCount = 0; loopCount < otherSpacer; loopCount++)
		{
			cout << "   "; 
			prevSpacer++; 
			colCount =+ otherSpacer;
		}
	}
}


And I get these errors now:

1. IntelliSense: too few arguments in function call - 212

2. error LNK2019: unresolved external symbol "void __cdecl wrapper(int,int)" (?wrapper@@YAXHH@Z) referenced in function "void __cdecl printCal(int,int,int,int,int,int,int)" (?printCal@@YAXHHHHHHH@Z)

3. error LNK2019: unresolved external symbol "void __cdecl spacer(int,int &,int,int &)" (?spacer@@YAXHAAHH0@Z) referenced in function "void __cdecl printCal(int,int,int,int,int,int,int)" (?printCal@@YAXHHHHHHH@Z)

4. error LNK2019: unresolved external symbol "void __cdecl printCal(int,int)" (?printCal@@YAXHH@Z) referenced in function _main

5. error LNK2019: unresolved external symbol "void __cdecl monthNums(int,int &,int &)" (?monthNums@@YAXHAAH0@Z) referenced in function "void __cdecl printCal(int,int,int,int,int,int,int)" (?printCal@@YAXHHHHHHH@Z)

6. error LNK2019: unresolved external symbol "void __cdecl monthNames(int)" (?monthNames@@YAXH@Z) referenced in function "void __cdecl printCal(int,int,int,int,int,int,int)" (?printCal@@YAXHHHHHHH@Z)

7. error LNK1120: 5 unresolved externals C:\Users\ethrtyiS\documents\visual studio 2010\Projects\calendar\Debug\calendar.exe 1
1
2
3
4
5
void monthNames(int count);
void dayNames();
void monthNums(int count, int& monthDays, int& spacerDays);
void spacer(int start, int& colCount, int count, int& prevSpacer);
void wrapper(int dayCount, int monthDays);


These should not be inside a function. Also your function prototype for printCal does not match the actual definition.

1
2
void printCal(int year, int start, int monthDays, int spacerDays, int prevSpacer, int dayCount = 1, int colCount = 0)     //this is the actual definition, takes at least 5 ints
void printCal(int year, int start);     //this is the prototype, takes two ints 


In your main you call it with two arguments, but the actual function takes at least 5.
Last edited on
Slicedpan, how do I go about not having them inside my function? Should I declare them like that but after namespace? Also, for the main should I include the other ints?
They can come either before or after the using statement (if they contain arguments that are in that namespace then they should be after, but this is not the case).

ethrtyiS wrote:

for the main should I include the other ints?


Probably, however I should be honest and say this code probably needs a rewrite, I really can't make sense of some of it, and even if you get it to compile I don't think it's going to do what you think it's going to do. I would go back to the drawing board tbh.

Hm, I've already rewrote it twice. I had this thing working just fine when I was using global variables. Now it just seems to have gone haywire. I just don't know what I am doing wrong. Can you give me an idea of how I should go about rewriting it if I do end up going that route again?
If you had it fine using global variables, then you should have stuck with that, for a small program like this, global variables are fine.
Right but my professor doesn't want us using global variables, which like I said earlier, made it very difficult.
That.... sucks. Well I would start from the version using global variables, since you know that works. First I would delete the global variables, and declare them instead inside the main function. Then try and work out which function needs which variables, and pass them down from one function to the next.
Topic archived. No new replies allowed.