Please Help with this link error

Every thing was ok till I tried to make an edit function in my program after doing the coding I keep on getting this error which says one of my functions are referred in another location below it the error.

Source.obj : error LNK2019: unresolved external symbol "struct stdDetails __cdecl updStdDetails(struct stdDetails,int)" (?updStdDetails@@YA?AUstdDetails@@U1@H@Z) referenced in function "void __cdecl ui(void)" (?ui@@YAXXZ)
1>E:\Users\SiNUX\Dropbox\Assigenments\PP Assignment\Program\VS2012\stdReg2\Debug\stdReg2.exe : fatal error LNK1120: 1 unresolved externals


This is my 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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
// e.cpp : Defines the entry point for the console application.

#include <iostream>

#include <string>

#include <cstring>

using namespace std;

//Struct Declaration for stdDetails
struct stdDetails {
	//I'm using a default Constructer to automatically initialise my member variables.

	//Default constructer start.
	stdDetails()	
		:stdNum(0)
		,stdAge(0)
		,conNum(0)
		,amtPaid(0)
	{
		memset(fName, 0, 25);
		memset(lName, 0, 25);
		memset(resAdd, 0, 100);
		memset(dBirth, 0, 10);
		memset(nicNum, 0, 10);
		memset(dateEnroll, 0, 10);
		memset(payMethod, 0, 10);
		memset(bksIssue, 0, 25);
	}
	//Default Constructer end

   	int stdNum; //Student Registration Number
    char fName[25]; // Student First Name
    char lName[25]; // Student Last Name
	char resAdd[100]; //Resident Address
	char dBirth[10]; // Student Date Of Birth
	int stdAge; // Student Age
	char nicNum[10]; // Sudent National ID number
	int conNum; // Student Contact Number
    char dateEnroll[10]; // Student Enrollment date
	char corsSelect[25]; // Course Selected
	char payMethod[10]; // Fee payment method
    double amtPaid; // Amount Student Paid for the course    
    char bksIssue[25]; //Issued Books
};


//Declartion of methods usend in this program
void ui(); //Method for displaying the UI
void output(stdDetails  stdDetailsArray);
stdDetails  enterDetails (stdDetails stdDetailsArray); //Method for entering student details to the prgoram
stdDetails updStdDetails (stdDetails stdDetailsArray, int stdNum);// new function
void entLine(); //To make interface more nice
void stars(); //Draws a line of stars to make CLI look more nice

//Declaration of i as a Variable for the counter
int i=0;

//Start of main method
int main(){

	ui();
    return 0;
}

//CLI method start from here on
void ui (){

    int  choice;
    stdDetails  stdDetailsArray;
	stdDetails  stdDetailsSearch[1000];
	char ansr = 'y';
	int search = 0;

	stars();
	cout<<"	        	Welcome to New Eastern Campus "<<endl;
	cout<<endl;
	stars();
	entLine();

//Beginning of the while loop which will display the options that user have to enter
		do{

			cout<<"		Press Number [1] for New Student Registration  : "<<endl;
			cout<<"		Press Number [2] to Search Student Details : "<<endl;
			cout<<"		Press Number [3] to Delete Student Details : "<<endl;
			cout<<"		Press Number [4] to View Student Details: "<<endl;
			cout<<"		Press Number [5] to Edit Student Details: "<<endl;
			entLine();
			cout<<"		Enter your choice here: ";
			cin>>choice;
			entLine();
//Start of the switch case for every choice selected will perform an action
			switch(choice){

//This Case will add the details entered to the stdDetails array
				case 1:
					stdDetailsArray = enterDetails(stdDetailsArray);
					stdDetailsSearch[i]=stdDetailsArray;
					i++;
				break;

//This Case will search the array for a given keyword 
				case 2:{
					int kWord;
					stdDetails  stdFindRes;
					cout<<"Enter the Student Registration Number of the Student: ";
					cin>>kWord;
						for(int x=0;x<i;x++){

						stdFindRes = stdDetailsSearch[x];

						if(kWord == stdFindRes.stdNum){

								search=1;

							break;
							}
						}
						if(search==1){
							output(stdFindRes);
						}else{
							cout<<"Student details not found please try again."<<endl;
							search = 0;
						}
					   }
				break;

//This case will delete the students details form the array 
				case 3:{
					search=0;
					int delStd,m;
					stdDetails  stdDel;
					cout<<"Enter the Registration Numeber of the student: ";
					cin>>delStd;
						for(m=0;m<i;m++){
						stdDel = stdDetailsSearch[m];
							if(delStd==stdDel.stdNum){
								search=1;
							break;
							}
						}
						if(search==1){
							for(int z=m;z<i;z++){
								stdDetailsSearch[z]=stdDetailsSearch[z+1];
								i--;
							}
						}else{
							cout<<"Std  not found"<<endl;
						}
					   }
				break;
//This case will display the student details
				case 4:
					cout<<"=================================="<<endl<<endl;;
					for(int x=0;x<i;x++){
						stdDetails  stdView = stdDetailsSearch[x];
						output(stdView);
						cout<<endl;
						cout<<"***********************************"<<endl;
						cout<<endl;
					}
					cout<<"=================================="<<endl;
				break;
//New part I added to the code
				case '5':{
					        int  kWord;
						int result;
						stdDetails  stdFindRes;
						cout<<"Enter the Registration Number of the Student: "<<endl;
						cin>> kWord;
						cout<<endl;
						for(int x=0;x<i;x++)
						{
							stdFindRes = stdDetailsSearch[x];
							if( kWord == stdFindRes.stdNum)
							{
								result = x;
								search=1;
							break;
							}
						}
						if(search==1)
						{
							stdDetailsArray = updStdDetails(stdFindRes, kWord);
							stdDetailsSearch[result]= stdDetailsArray;
						}
						else
						{
							cout<<"Student Not Found"<<endl;
						}
					}
				break;
//The default message if  any thing goes wrong
				default:
					cout<<"Invalid Option Please Enter a Valid Entry"<<endl;
					break;
				}

//The option case list ends from here
				entLine();
				cout<<"Continue [y/n]: ";
				cin>>ansr;
				entLine();
			}while(ansr == 'y'||ansr == 'Y');

//While Loop Ends here

			cout<<"Thank You"<<endl;
}
//Ending of the UI system

//This method is used to decorate the interface
void entLine(){
	cout<<endl;
    cout<<endl;
}
//Method End

//Data Display Method Starts from here
void output(stdDetails  stdDetailsArray){
    cout<<"Student Registration Number: "<<stdDetailsArray.stdNum<<endl;
    cout<<"Student First Name: "<<stdDetailsArray.fName<<endl;
    cout<<"Student Last Name: "<<stdDetailsArray.lName<<endl;
	cout<<"Student Resident Address: "<<stdDetailsArray.resAdd<<endl;
	cout<<"Student Date Of Birth: "<<stdDetailsArray.dBirth<<endl;
	cout<<"Student Age: "<<stdDetailsArray.stdAge<<endl;
	cout<<"Student National ID number: "<<stdDetailsArray.nicNum<<endl;
	cout<<"Student Contact Number: "<<stdDetailsArray.conNum<<endl;
	cout<<"Student Enrollment Date: "<<stdDetailsArray.dateEnroll<<endl;
	cout<<"Selected Course: "<<stdDetailsArray.corsSelect<<endl;
	cout<<"Payment Mthod: "<<stdDetailsArray.payMethod<<endl;
	cout<<"Paid Amount: "<<stdDetailsArray.amtPaid<<endl;
	cout<<"Books Issued: "<<stdDetailsArray.bksIssue<<endl;
}
//Data Display Method Ends

//Data Entery Method start from here
stdDetails  enterDetails (stdDetails  stdDetailsArray){

	cout<<"Enter Student Registration Number : ";
	cin>>stdDetailsArray.stdNum;
	cout<<"Enter Sutdent Firs Name : ";
	cin>>stdDetailsArray.fName;
	cout<<"Enter Student Last Name : ";
	cin>>stdDetailsArray.lName;
	cout<<"Enter Student Resident Address : ";
	cin>>stdDetailsArray.resAdd;
	cout<<"Enter Student DoB : ";
	cin>>stdDetailsArray.dBirth;
	cout<<"Enter Student Age : ";
	cin>>stdDetailsArray.stdAge;
	cout<<"Enter Student NIC number : ";
	cin>>stdDetailsArray.nicNum;
	cout<<"Enter Student Contact number : ";
	cin>>stdDetailsArray.conNum;
	cout<<"Enter Student Enrollment Date : ";
	cin>>stdDetailsArray.dateEnroll;
	cout<<"Selected Course : ";
	cin>>stdDetailsArray.corsSelect;
	cout<<"Payment Method : ";
	cin>>stdDetailsArray.payMethod;
	cout<<"Amount Paid : ";
	cin>>stdDetailsArray.amtPaid;
	cout<<"Books Issued : ";
	cin>>stdDetailsArray.bksIssue;
	return stdDetailsArray;
}
//Data Entry  Method End

//CLI Line of stars
void stars(){
for (int i=1; i<=160; i++) {
	cout << "*";
}
cout << endl;
}
The linker does not see the definition of the function. I also do not see the definition. Maybe it is you who knows where the function is defined?
1
2
3
4
5
6
7
//Declartion of methods usend in this program
void ui(); //Method for displaying the UI
void output(stdDetails  stdDetailsArray);
stdDetails  enterDetails (stdDetails stdDetailsArray); //Method for entering student details to the prgoram
stdDetails updStdDetails (stdDetails stdDetailsArray, int stdNum);// new function
void entLine(); //To make interface more nice
void stars(); //Draws a line of stars to make CLI look more nice 


above is the place where all the function are defined.

Below is the two parts which gives me the issue.

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
case '5':{
					        int  kWord;
						int result;
						stdDetails  stdFindRes;
						cout<<"Enter the Registration Number of the Student: "<<endl;
						cin>> kWord;
						cout<<endl;
						for(int x=0;x<i;x++)
						{
							stdFindRes = stdDetailsSearch[x];
							if( kWord == stdFindRes.stdNum)
							{
								result = x;
								search=1;
							break;
							}
						}
						if(search==1)
						{
							stdDetailsArray = updStdDetails(stdFindRes, kWord);
							stdDetailsSearch[result]= stdDetailsArray;
						}
						else
						{
							cout<<"Student Not Found"<<endl;
						}
					}
				break;



//Data Entery Method start from here
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
stdDetails  enterDetails (stdDetails  stdDetailsArray){

	cout<<"Enter Student Registration Number : ";
	cin>>stdDetailsArray.stdNum;
	cout<<"Enter Sutdent Firs Name : ";
	cin>>stdDetailsArray.fName;
	cout<<"Enter Student Last Name : ";
	cin>>stdDetailsArray.lName;
	cout<<"Enter Student Resident Address : ";
	cin>>stdDetailsArray.resAdd;
	cout<<"Enter Student DoB : ";
	cin>>stdDetailsArray.dBirth;
	cout<<"Enter Student Age : ";
	cin>>stdDetailsArray.stdAge;
	cout<<"Enter Student NIC number : ";
	cin>>stdDetailsArray.nicNum;
	cout<<"Enter Student Contact number : ";
	cin>>stdDetailsArray.conNum;
	cout<<"Enter Student Enrollment Date : ";
	cin>>stdDetailsArray.dateEnroll;
	cout<<"Selected Course : ";
	cin>>stdDetailsArray.corsSelect;
	cout<<"Payment Method : ";
	cin>>stdDetailsArray.payMethod;
	cout<<"Amount Paid : ";
	cin>>stdDetailsArray.amtPaid;
	cout<<"Books Issued : ";
	cin>>stdDetailsArray.bksIssue;
	return stdDetailsArray;
}

Last edited on
above is the place where all the function are defined.

Um, no. You've declared the function there, but nowhere in the code you've posted is there a definition of what the updStdDetails function actually does.
1
2
3
4
5
6
7
//Declartion of methods usend in this program
void ui(); //Method for displaying the UI
void output(stdDetails  stdDetailsArray);
stdDetails  enterDetails (stdDetails stdDetailsArray); //Method for entering student details to the prgoram
stdDetails updStdDetails (stdDetails stdDetailsArray, int stdNum);// new function
void entLine(); //To make interface more nice
void stars(); //Draws a line of stars to make CLI look more nice  


above is the place where all the function are defined.


Correction - Above is where the functions are declared not defined

Defining a function is to provide an implementation for it, however you haven't provided an implementation for
stdDetails updStdDetails (stdDetails stdDetailsArray, int stdNum);

But you're using it here:
1
2
3
4
5
if(search==1)
{
	stdDetailsArray = updStdDetails(stdFindRes, kWord);
	stdDetailsSearch[result]= stdDetailsArray;
}


*edit - Ninja'd
Last edited on
Oh damn yeah there's no function for updStdDeatils I missed it with this error. Ok let me ask it this way will I be able to get the data using updStdDeatils and then update them using my data enter field.
Topic archived. No new replies allowed.