Try to get rid of that antique Turbo C++ 3 which was obsolete 10 years ago. You can get an excellent free IDE, Code::Blocks with mingw compiler (GNU C compiler for windows) and join the modern world.
Meanwhile:
#include<fstream.h> // modern compilers use #include <fstream>
#include<iostream.h> // modern compilers use #include <iostream>
using namespace std; // needed by modern c++ compilers, maybe not for Turbo
//#include<conio.h> // not used in standard c++
class student
{
int rollno;
char name[20];
int tm;
public:
void input();
void transfer();
void output();
}; // terminate the class definition here
//obj; // *************don't instantiate an object in the class definition
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* )this,sizeof( student ) ); //******* use "this" pointer and sizeof(student)
cout<<"Wish to enter more(Y/N)?\n";
cin>>ch;
}
outf.close();
}
void student::transfer()
{
ofstream outf;
ifstream inf;
inf.open( "mark.dat" );
outf.open( "trans.dat" );
// **********when you do this you put an extra copy of the last student in outf
// while ( inf )
// {
// instead, read inside the loop control expression this way:
while( inf.read(( char* )this,sizeof( student ) ) ) { // ********use "this" pointer and sizeof(student)
outf.write(( char* )this,sizeof( student ) ); // *********use "this" pointer and sizeof(student)
}
outf.close();
inf.close();
}
void student::output()
{
ifstream inf;
inf.open( "trans.dat" );
// while ( inf ) //******* here you're printing yet another extra copy of the last student
while (inf.read((char*)this, sizeof(student))) // ******* again, read inside loop control expression
{
// inf.read(( char* )this,sizeof( student ) );
cout<<"\nRollno "<<rollno;
cout<<"\nName "<<name;
cout<<"\nTotal "<<tm;
}
inf.close();
}
int main() // ************ return type of main should be int
{
// clrscr();
student obj;
obj.input();
obj.transfer();
obj.output();
getchar(); //******* I guess getch() is a Turbo C thing; I think not used in most modern compilers
return 0;
}