943,810 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 2121
  • C++ RSS
Feb 24th, 2009
0

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

Expand Post »
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<fstream.h>
#include<iostream.h>
#include<conio.h>
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"<<rollno;
cout<<"Name"<<name;
cout<<"Total"<<tm;
}
getch();
inf.close();
}

The error i get is
compiling 10.cpp
linking ...\OUTPUT\10.EXE
.Linker Error: Undefined symbol _main in module c0.ASM

I think the error is due to the missing of void main. But i don't know where i should put it.
Reputation Points: 53
Solved Threads: 33
Posting Whiz in Training
bugmenot is offline Offline
224 posts
since Nov 2006
Feb 24th, 2009
0

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

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?
Reputation Points: 53
Solved Threads: 33
Posting Whiz in Training
bugmenot is offline Offline
224 posts
since Nov 2006
Feb 24th, 2009
0

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

I found the error and corrected it.
#include<fstream.h>
#include<iostream.h>
#include<conio.h>
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"<<rollno;
cout<<"Name"<<name;
cout<<"Total"<<tm;
}
inf.close();
}
void main()
{
student obj;
obj.input();
obj.transfer();
obj.output();
getch();
}
Reputation Points: 53
Solved Threads: 33
Posting Whiz in Training
bugmenot is offline Offline
224 posts
since Nov 2006
Feb 24th, 2009
0

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

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
Last edited by bugmenot; Feb 24th, 2009 at 12:20 pm.
Reputation Points: 53
Solved Threads: 33
Posting Whiz in Training
bugmenot is offline Offline
224 posts
since Nov 2006
Mar 4th, 2010
-2

find my errors

C++ Syntax (Toggle Plain Text)
  1. char str[] = 'stop';
  2. if (isupper (str) =="STOP")
  3. exit(0);
Last edited by Nick Evan; Mar 4th, 2010 at 1:38 pm. Reason: Added code-tags
Reputation Points: 8
Solved Threads: 0
Newbie Poster
toadily8 is offline Offline
1 posts
since Mar 2010

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: postfix expression with stacks
Next Thread in C++ Forum Timeline: ERROR





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC