954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Please find and correct the error in my c++ program. "Linker Error: Undefined symbol

Please find and correct the error in my c++ program. "Linker Error: Undefined symbol _main in module c0.ASM"
The program is for transfering content of one file to another.

#include
#include
#include
class student
{
int rollno;
char name[20];
int tm;
public:
void input();
void transfer();
void output();
}
obj;
void student::input()
{
char ch='y';
ofstream outf;
outf.open("mark.dat");
while(ch=='y')
{
cout<<"Enter rollno, name and mark";
cin>>rollno>>name>>tm;
outf.write((char*)&obj,sizeof(obj));
cout<<"wish to enter more(Y/N)";
cin>>ch;
}
outf.close();
}
void student::transfer()
{
ofstream outf;
ifstream inf;
inf.open("mark.dat");
inf.open("trans.dat");
while(inf)
{
inf.read((char*)&obj,sizeof(obj));
outf.write((char*)&obj,sizeof(obj));
}
outf.close();
inf.close();
}
void student::output()
{
ifstream inf;
inf.open("trans.dat");
while(inf)
{
inf.read((char*)&obj,sizeof(obj));
cout<<"Rollno"<

bugmenot
Posting Whiz in Training
225 posts since Nov 2006
Reputation Points: 53
Solved Threads: 34
 

think i got this from my friend

void main()
{
student obj;
obj.input();
obj.transfer();
obj.output();
getch();
}

He told to put it at last but hwo do i do that?

bugmenot
Posting Whiz in Training
225 posts since Nov 2006
Reputation Points: 53
Solved Threads: 34
 

I found the error and corrected it.
#include
#include
#include
class student
{
int rollno;
char name[20];
int tm;
public:
void input();
void transfer();
void output();
}
obj;
void student::input()
{
char ch='y';
ofstream outf;
outf.open("mark.dat");
while(ch=='y')
{
cout<<"Enter rollno, name and mark";
cin>>rollno>>name>>tm;
outf.write((char*)&obj,sizeof(obj));
cout<<"wish to enter more(Y/N)";
cin>>ch;
}
outf.close();
}
void student::transfer()
{
ofstream outf;
ifstream inf;
inf.open("mark.dat");
inf.open("trans.dat");
while(inf)
{
inf.read((char*)&obj,sizeof(obj));
outf.write((char*)&obj,sizeof(obj));
}
outf.close();
inf.close();
}
void student:utput()
{
ifstream inf;
inf.open("trans.dat");
while(inf)
{
inf.read((char*)&obj,sizeof(obj));
cout<<"Rollno"<

bugmenot
Posting Whiz in Training
225 posts since Nov 2006
Reputation Points: 53
Solved Threads: 34
 

I still have another problem. That is when the while loop asks continue(y/n)
When i enter n it just stuck there.

I need to make the program error free urgently. Please reply with solution. I use borland turbo c++ 3

bugmenot
Posting Whiz in Training
225 posts since Nov 2006
Reputation Points: 53
Solved Threads: 34
 
char str[] = 'stop';
if (isupper (str) =="STOP")
exit(0);
toadily8
Newbie Poster
1 post since Mar 2010
Reputation Points: 8
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You