error C2248: function-style initializer appears to be a function definition
hello there, i am new in c plus plus and i got this problem with my assignment. i hope someone would help me solve this problem. thanks a lot.
#include <iostream>
#include <fstream>
#include <cstdio>
using namespace std;
struct detail
{
char lname[15];
char fname[15];
int date;
int month;
int year;
char address[200];
};
detail x;
void add_record();
void search_birth(int, int, int);
void search_fname(char);
int main()
{
char input;
cout << "*************************************************" << endl;
cout << "***** Welcome to your Personal Address Book *****" << endl;
cout << "***** (a)\t Add new person\t\t *****" << endl;
cout << "***** (b)\t Search on birth date\t *****" << endl;
cout << "***** (f)\t Search on family name\t *****" << endl;
cout << "***** (q)\t Quit\t\t\t *****" << endl;
cout << "*************************************************" << endl << endl;
cout << "Please select an option: ";
cin.get(input);
switch(input)
{
case 'A' : case 'a': add_record();
break;
case 'B': case 'b': search_birth(x.date, x.month, x.year);
break;
case 'F': case 'f': search_fname(x.fname[15]);
break;
case 'Q': case 'q':
break;
default: cout << "Invalid Input!" << endl;
}
return 0;
}
void add_record()
{
ofstream outFile("contact.txt");
cout << "Enter new contact's family name: ";
cin.getline(x.fname, sizeof(x.fname));
cout << "Enter new contact's name: ";
cin.getline(x.lname, sizeof(x.lname));
cout << "Enter new contact's date of birth(date): ";
cin >> x.date;
cout << "Enter new contact's date of birth(month): ";
cin >> x.month;
cout << "Enter new contact's date of birth(year): ";
cin >> x.year;
cout << "Enter new contact's address: ";
cin.getline(x.address, sizeof(x.address));
outFile << " " << x.fname << " " << x.lname << " " << x.date << " " << x.month << " " << x.year << " " << x.address;
outFile.close();
}
void search_birth(x.date, x.month, x.year)
{
int date;
int month;
int year;
cout << "Enter the date of birth(date): ";
cin >> date;
cout << endl;
cout << "Enter the date of birth(month): ";
cin >> month;
cout << endl;
cout << "Enter the date of birth(year): ";
cin >> year;
cout << endl;
ifstream inFile("contact.txt");
while(!inFile.eof())
{
x.date == date;
x.month == month;
x.year == year;
cout << x.lname << " " << x.fname << endl;
cout << x.date << "/" << x.month << "/" << x.year << endl;
cout << x.address << endl;
}
inFile.close();
}
void search_fname(x.fname)
{
char name[15];
cout << "Enter family name: ";
cin.getline(name, sizeof(name));
ifstream inFile("contact.txt");
while(!inFile.eof())
{
if(strcmp(name, x.fname) == 0)
{
cout << x.lname << " " << x.fname << endl;
cout << x.date << "/" << x.month << "/" << x.year << endl;
cout << x.address << endl;
}
else
{
cout << "No data found." << endl;
}
}
inFile.close();
}
|
after i edit my source code up and down, it still come with these errors:
1 - error LNK2019: unresolved external symbol " char__cdecl search_birth(char)"(?search_birth@@YADD@Z) referenced in function main
2 - fatal error LNK1120: 1 unresolved externals
can someone guide me how to solve these problems??
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
|
#include <iostream>
#include <fstream>
#include <cstdio>
using namespace std;
struct detail
{
char lname[15];
char fname[15];
char date[10];
char phone[15];
char address[200];
};
detail x;
void add_record();
char search_birth(char);
void search_fname();
void menu();
int main()
{
char input;
char decision;
char i[10];
START:
system("CLS");
cin.clear();
menu();
cout << "Please select an option: ";
cin.get(input);
switch(input)
{
case 'A' : case 'a': add_record();
goto START;
break;
case 'B': case 'b':
cout << "Enter the date of birth: ";
cin.getline(x.date, sizeof(x.date));
i[10] = search_birth(x.date[10]);
cout << "D.O.B: " << i[10] << endl;
goto START;
break;
case 'F': case 'f': search_fname();
break;
case 'Q': case 'q':
break;
default: cout << "Invalid Input!" << endl;
}
return 0;
}
void menu()
{
cout << "*************************************************" << endl;
cout << "***** Welcome to your Personal Address Book *****" << endl;
cout << "***** (a)\t Add new person\t\t *****" << endl;
cout << "***** (b)\t Search on birth date\t *****" << endl;
cout << "***** (f)\t Search on family name\t *****" << endl;
cout << "***** (q)\t Quit\t\t\t *****" << endl;
cout << "*************************************************" << endl << endl;
}
void add_record()
{
system("CLS");
cin.clear();
cin.ignore();
ofstream outFile("contact.txt", ios::app);
cout << "Please enter the christian name of the person to be added: ";
cin.getline(x.lname, sizeof(x.lname));
cout << "Please enter the family name of the person to be added: ";
cin.getline(x.fname, sizeof(x.fname));
cout << "Please enter an address for " << x.lname << " " << x.fname << " : ";
cin.getline(x.address, sizeof(x.address));
cout << "Please enter a phone number for " << x.lname << " " << x.fname << " : ";
cin.getline(x.phone, sizeof(x.phone));
cout << "Please enter a birth date for " << x.lname << " " << x.fname << " : ";
cin.getline(x.date, sizeof(x.date));
outFile << " " << x.lname << " " << x.fname << endl;
outFile << " " << x.address << endl;
outFile << " " << x.phone << endl;
outFile << " " << x.date << endl;
outFile << " " << endl;
outFile.close();
cout << endl << endl;
cout << x.lname << " " << x.fname << " successfully added to address book." << endl << endl;
}
char search_birth(char dob[10])
{
system("CLS");
cin.clear();
cin.ignore();
ifstream inFile("contact.txt");
while(!inFile.eof())
{
if(strcmp(dob, x.date) == 0)
{
cout << x.lname << " " << x.fname << endl;
cout << x.address << endl;
cout << "Tel: " << x.phone << endl;
}
}
inFile.close();
return dob[10];
}
void search_fname()
{
char name[15];
cout << "Enter family name: ";
cin.getline(name, sizeof(name));
ifstream inFile("contact.txt");
while(!inFile.eof())
{
if(strcmp(x.fname, name) == 0)
{
cout << x.lname << " " << x.fname << endl;
cout << x.address << endl;
cout << "Tel: " << x.phone << endl;
cout << "D.O.B: " << x.date << endl;
}
else
{
cout << "No data found." << endl;
}
}
inFile.close();
}
|
Your declaration of search_birth on line 17 does not match that on line 96
Topic archived. No new replies allowed.