Help needed : getting LNK2019: unresolved external symbol "void_cdecl ..." error

Thank you everyone. We were able to progress.
However I am unable to append file.
I put the app while opening the filing but it is not happening still.
Actually each time a user opens the code to enter data the no, of house and families should become the older values plus new which the user is going the enter.
for eg:
If i already have 3 houses, next time i open and say "No .of enteries =2" it should become 5.
But it displays 2 only.
It is not counting the enteries which are already present.
Can you please help in this regard.Below is my modified program.
< #include<iostream>
#include<conio.h>
#include<fstream>
using namespace std;
static int NumOfHouses; //global variable for number of houses
static int NumOfVehicles; //global variable for number of vehicles
void StartCensus();
class Community
{
private:
int NumOfMem; //no. of members in a family
public:
int Hno; //house number
int NumOfFamilies; //no. of families
void GetDetails();
void ShowDetails();
Community() //Default constructor
{
Hno=1000;
}
};
class Transport:public Community
{
public:
int NumOfVehicles1; //no. of veicles owned
char Type[20]; //type could be four/two wheeler
void GetTransport();
void ShowTransport();
Transport() //default constructor
{
strcpy(Type,"Four Wheeler");
}
};
void Community::GetDetails()
{
cout<<"Enter house number:";
cin>>Hno;
cout<<"Enter number of members in family:";
cin>>NumOfMem;
NumOfHouses+=1;
}
void Community::ShowDetails()
{
cout<<"\nLatest count of Number of families is:"<<NumOfHouses;
}
void Transport::GetTransport()
{
cout<<"No. of vehicles owned:";
cin>>NumOfVehicles1;
NumOfVehicles=NumOfVehicles+NumOfVehicles1;
cout<<"Type of vehicles:\n";
for(int i=0;i<NumOfVehicles1;i++)
{
cout<<i+1<<" Vehicle type:";
cin>>Type;
}
}
void Transport::ShowTransport()
{
cout<<"\nLatest count of Vehicles is:"<<NumOfVehicles;
}
void main()
{
ofstream fout;
fout.open("D:\\TRANSPORT15.dat",ios::out|ios::binary);
if(!fout)
{
cout<<"\nERROR IN OPENING FILE";
}
else
{
cout<<"\nFile opened";
}
fout.close();
StartCensus();
getch();
return;
}
void StartCensus()
{
Transport t;
ofstream fout1;
int i,p;
fout1.open("D:\\TRANSPORT15.dat",ios::binary|ios::in|ios::app);
if(!fout1) //checking if file is opened
{
cout<<"\nError occured in opening file";
cout<<"\nPlease try again";
return;
}
cout<<"\nNo of records:"; //entry for records
cin>>i;
fout1.write((char*)NumOfHouses,sizeof(NumOfHouses));
fout1.write((char*)NumOfHouses,sizeof(NumOfHouses));
for(p=0;p<i;p++)
{
t.GetDetails();
fout1.write((char*)&t,sizeof(t));
t.GetTransport();
fout1.write((char*)&t,sizeof(t));
}
cout<<"\n\nData recorded to file";
t.ShowDetails();
t.ShowTransport();
fout1.close();
return ;
} >

Thanks
Last edited on
I get no such error compiling with Visual Studio.

You have a couple of other problems though.

Line 38: strcpy_s(Type,"Four Wheeler");
Type is only 10 characters. You're trying to copy a 12 character string into string that can only hold 10 characters. You should consider using std::string instead of a C string.

Line 61: cin.getline(Type,30);
You're trying to read in up to 30 characters into a 10 character string.

Line 69: main() must be type int.

PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
closed account (SECMoG1T)
i agree with @AbstractionAnon and also note another error in your stream open function e.g
 
fin1.open("C:\\Census.dat",ios::binary||ios::in);


binary or "|" should be used instead of logical or "||"

Another error, on several lines (throughout the program):

The logical or operator || is wrongly used:
 
    ios::binary || ios::in


It should be the bitwise or operator |
 
    ios::binary | ios::in


- check every file open statement, they all need correcting.
Topic archived. No new replies allowed.