How to fix this error..

C++ code about library management systems.Illegal user of pointer in m

Page 1 of 1

7 Replies - 811 Views - Last Post: 24 May 2009 - 05:11 AM Rate Topic: -----

#1 shivanigandhi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 24-May 09

How to fix this error..

Posted 24 May 2009 - 04:10 AM

Hello,
I have the code below. I am new programmer in cpp.Rather this is the first time i am coding. I am getting 2 errors.
1. Illegal use of pointer in main funciton
2. Operator cannot be applied to these operand types in function main().
Please help me if possible.
#include<stdio.h>
#include<iostream.h>
#include<stdlib.h>
#include<conio.h>
#include<fstream.h>


void main()
{
	
	int choice;
	char user[7];char password[8];
	char inLine[40][80], borrowed[50];
	char fname[20];
	char issue='I';
	char item_id[6];
	ifstream inFile;
	cout<<"\n Welcome to Magenta Library\n";
	cout<<"PLease Enter Your User Name";
	cin>>user;
	cout<<"Please Enter your Password";
	cin>>password;

	 cout<<"Your user name is\t"<<user<<endl;
	 cout<<"Your Password is\t"<<password<<endl;
	 loop:
	 cout<<"\n**************Welcome to MAGENTA LIBRARY************"<<endl;
	 cout<<"\nPlease enter the operation you wish to perform from the menu"<<endl;
	 cout<<"\n 1. Borrow an ITEM"<<endl;
	 cout<<"\n 2. Extend an ITEM"<<endl;
	 cout<<"\n 3. Return an ITEM"<<endl;
	 cout<<"\n 4. Exit from the system"<<endl;
	 cin>>choice;
	 clrscr();
	 switch(choice)
	 {
	   case 1:
		  cout<<"Borrows an item"<<endl;

		  
		  cout<<user;
		  cout<<"\n********Please select the item you wish to borrow********"<<endl;
		  loop1:
		cout<<"Please enter the Item_id";
		cin>>item_id;

			inFile.open("C:\\TC\\BIN\\Try.txt",ios::in);

			if(!inFile.fail())
			{
				while(!inFile.eof())
				{
					for(int i=0;i<=sizeof(inLine);i++)
					{
					  for(int j=0;j<=5;j++)
					  {
						if(inLine[i][j]==item_id[j])
						{
							if(inLine[i][5]==item_id[5])
							{
									inLine[i][75]=issue;// changing the status of book from available'a' to issues 'i'
									inFile>>inLine;
									cout<<inLine;
									inFile.close();

							}
							else
							{
								cout<<"Please enter the correct Item_id";
								goto loop1;
							}
						}	  


					  }
						}
				}
				   

			}else
				cout<<"Error opening File";
			cout<<"\nPlease Enter the Book Id you wish to Borrow";
			cin>>item_id;
			
			cout<<"Item you have borrowed is"<<item_id;
			break;	  
	   case 2:
		  void extend(int user);
		  cout<<"Extend an item"<<endl;
		  break;
	   case 3:
			   cout<<"Return an item"<<endl;
		   void submit(int user);
		  break;
	   case 4:
		   exit(0);  
	   default:
		   cout<<"Please enter a correct option";
		   //continue;
	 }
  }

return 0;
}


This post has been edited by shivanigandhi: 24 May 2009 - 04:43 AM


Is This A Good Question/Topic? 0
  • +

Replies To: How to fix this error..

#2 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: How to fix this error..

Posted 24 May 2009 - 04:13 AM

Welcome to DIC!

Please edit your posting (see the "EDIT" button in lower right).
( a ) Delete all your code.
( b ) Get a fresh copy of the code with formatting in place from your editor / IDE.
( c ) Paste the formatted code between code tags like this :code:
( d ) Use the "Preview Post" button to check it's all good.
( e ) Use the "Submit Modified Post" button to finish the editing.



1 - When writing in C++ use C++ headers in your #includes instead of C ones.
#warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.


2 - error: ‘::main’ must return ‘int’
"void main()" is wrong. Always use "int main()".
Read here the words of the man who invented C++:
http://www.research.....html#void-main
Can I write "void main()"?
The definition
void main() { /* ... */ }
is not and never has been C++, nor has it ever been C. See the ISO C++ standard 3.6.1[2] or the ISO C standard 5.1.2.2.1.

This post has been edited by janotte: 24 May 2009 - 04:18 AM

Was This Post Helpful? 0
  • +
  • -

#3 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: How to fix this error..

Posted 24 May 2009 - 04:26 AM

Gosh. Ummm it's very hard to know how to read your code even with some formatting.

Could you please highlight where the end of the main() function is?
And the end of all the functions while you are at it.

It seems, at a quick look, that you have functions nested inside other functions.
If you do then this is a very bad idea.

Anyway just clear this up for me by going through your code and adding comments like this after the closing brace for all the functions
} // end of function named ................()



And then posting the code again in a new reply.

I am assuming that this is not your first program ever. You do have some experience in coding in other languages don't you?
If this is your first program in any language then you have bitten off too much at once and probably need to go back to much simpler programs and build up to this level over a few stages.

I am assuming you have experience in some other language/s and will talk to you on that basis unless you tell me I am wrong.

This post has been edited by janotte: 24 May 2009 - 04:34 AM

Was This Post Helpful? 0
  • +
  • -

#4 deery5000  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 966
  • Joined: 09-May 09

Re: How to fix this error..

Posted 24 May 2009 - 04:33 AM

// DIC help file.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


#include<iostream>
#include "windows.h"
#include<fstream>

using namespace std;


void main()
{
	//user uobj;
	int choice;
	char user[7];char password[8];
	char inLine[40][80];  char borrowed[50];
	char fname[20];
	char issue='I';
	char item_id[6];
	ifstream inFile;
	cout<<"\n Welcome to Magenta Library\n";
	cout<<"PLease Enter Your User Name";
	cin>>user;
	cout<<"Please Enter your Password";
	cin>>password;

	 cout<<"Your user name is\t"<<user<<endl;
	 cout<<"Your Password is\t"<<password<<endl;
	
	 cout<<"\n**************Welcome to MAGENTA LIBRARY************"<<endl;
	 cout<<"\nPlease enter the operation you wish to perform from the menu"<<endl;
	 cout<<"\n 1. Borrow an ITEM"<<endl;
	 cout<<"\n 2. Extend an ITEM"<<endl;
	 cout<<"\n 3. Return an ITEM"<<endl;
	 cout<<"\n 4. Exit from the system"<<endl;
	 cin>>choice;
	system("clr");
	 switch(choice)
	 {
	   case 1:
		  cout<<"Borrows an item"<<endl;

		  
		  cout<<user;
		  cout<<"\n********Please select the item you wish to borrow********"<<endl;
		  

		loop1:
		cout<<"Please enter the Item_id";
		cin>>item_id;

			inFile.open("C:\\TC\\BIN\\Try.txt",ios::in);

			if(!inFile.fail())
			{
				while(!inFile.eof())
				{
					for(int i=0;i<=sizeof(inLine);i++)
					{
					  for(int j=0;j<=5;j++)
					  {
						if(inLine[i][j]==item_id[j])
						{
							if(inLine[i][5]==item_id[5])
							{
									inLine[i][75]=issue;
									inFile>>issue;
									cout<<inLine;
									inFile.close();

							}
							else
							{
								cout<<"Please enter the correct Item_id";
								goto loop1;
							}
						}	  


					  }
					   }
				}
				   

			}else
				cout<<"Error opening File";
			cout<<"\nPlease Enter the Book Id you wish to Borrow";
			cin>>item_id;
			
			cout<<"Item you have borrowed is"<<item_id;
			break;	  
	   case 2:
		  void extend(int user);
		  cout<<"Extend an item"<<endl;
		  break;
	   case 3:
			   cout<<"Return an item"<<endl;
		   void submit(int user);
		  break;
	   case 4:
		   exit(0);  
	   default:
		   cout<<"Please enter a correct option";
		   //continue;
	 }
   void  verification(char user,char password);
}


char borrow(int user)
{

   char data[80];
   ofstream outfile;
   char inLine[500];
   char fname[20];
   char abc = 'abc';
   ifstream inFile;
   cout<<user;
   outfile.open("C:\\TC\\BIN\\Try.txt",ios::app,ios::out);
   if(!inFile.fail())
		  {
		while(!inFile.eof())
		{
			inFile>>inLine;
			if(inLine=="item_id")
		 {
			cin>>abc;
		 }
		 cout<<inLine<<endl;
		}

   cout<<"Writing to the file"<<endl;
   cout<<"enter your data:\t";
   cin.getline(data,80);
   outfile<<data<<endl;
   cout<<"Enter the class name:\t";
   cin>>data;
   cin.ignore();
   outfile<<data<<endl;
   outfile.close();

		  char inLine[500];
		  char fname[20];
		  ifstream inFile;
		  inFile.open("C:\\TC\\BIN\\Try.txt",ios::in);

		  if(!inFile.fail())
		  {
		while(!inFile.eof())
		{
		 inFile>>inLine;
		 cout<<inLine<<endl;
		}
		   inFile.close();
		  }else
		   cout<<"Error opening File";
   return 0;
}
	cout<<"you have borrowed a book successfully";

  /*
   int c=1;
   file fp;
   fp=fopen("filename.dat","rb+");
   long recsize;
   recsize=sizeof(B);
   rewind(fp);
   clrscr();
   gotoxy(3,4);cprintf("	[Books]		");
   gotoxy(2,7);cout<<"book_no.	Book_name	Author	Publication	Price";

   gotoxy(2,8);cout<<"----------------------------------------------------------";
   while(fread(&b,resize,1,fp)==1)
   {
	cprintf("	[BOOKS]		");


   }
	*/
	return 0;
}
void submit(int user)
{
  cout<<user<<endl;
}
void extend(int user)
{
	cout<<user<<endl;
}



program runs now, but still some errors

Kevin

This post has been edited by deery5000: 24 May 2009 - 04:41 AM

Was This Post Helpful? 0
  • +
  • -

#5 shivanigandhi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 24-May 09

Re: How to fix this error..

Posted 24 May 2009 - 04:39 AM

hi Kevin,
Yes i do know that. But then what difference does it make if I set it with some other value and then use it.

View Postdeery5000, on 24 May, 2009 - 03:33 AM, said:

oops lol

Hi mate, you should format your code correctly before posting next time, makes it easier to read.

ive noticed a problem

inLine[i][75]=issue;




issue is set to "I"?

Have a look at that.

Kevin

Was This Post Helpful? 0
  • +
  • -

#6 deery5000  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 966
  • Joined: 09-May 09

Re: How to fix this error..

Posted 24 May 2009 - 04:42 AM

this is working now

need file to read from
// DIC help file.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


#include<iostream>
#include "windows.h"
#include<fstream>

using namespace std;


int main()
{
	//user uobj;
	int choice;
	char user[7];
	char password[8];
	char inLine[40][80]; 
	// char borrowed[50];
	// char fname[20];
	char issue='I';
	char item_id[6];
	ifstream inFile;
	cout<<"\n Welcome to Magenta Library\n";
	cout<<"PLease Enter Your User Name";
	cin>>user;
	cout<<"Please Enter your Password";
	cin>>password;

	 cout<<"Your user name is\t"<<user<<endl;
	 cout<<"Your Password is\t"<<password<<endl;
	
	 cout<<"\n**************Welcome to MAGENTA LIBRARY************"<<endl;
	 cout<<"\nPlease enter the operation you wish to perform from the menu"<<endl;
	 cout<<"\n 1. Borrow an ITEM"<<endl;
	 cout<<"\n 2. Extend an ITEM"<<endl;
	 cout<<"\n 3. Return an ITEM"<<endl;
	 cout<<"\n 4. Exit from the system"<<endl;
	 cin>>choice;
	
	 system("cls");
	 switch(choice)
	 {
	   case 1:
		  cout<<"Borrows an item"<<endl;

		  
		  cout<<user;
		  cout<<"\n********Please select the item you wish to borrow********"<<endl;
		  

		loop1:
		cout<<"Please enter the Item_id";
		cin>>item_id;

			inFile.open("C:\\TC\\BIN\\Try.txt",ios::in);

			if(!inFile.fail())
			{
				while(!inFile.eof())
				{
					for(int i=0;i<=sizeof(inLine);i++)
					{
					  for(int j=0;j<=5;j++)
					  {
						if(inLine[i][j]==item_id[j])
						{
							if(inLine[i][5]==item_id[5])
							{
									inLine[i][75]=issue;
									inFile>>issue;
									cout<<inLine;
									inFile.close();

							}
							else
							{
								cout<<"Please enter the correct Item_id";
								goto loop1;
							}
						}	  


					  }
					   }
				}
				   

			}else
				cout<<"Error opening File";
			cout<<"\nPlease Enter the Book Id you wish to Borrow";
			cin>>item_id;
			
			cout<<"Item you have borrowed is"<<item_id;
			break;	  
	   case 2:
		  void extend(int user);
		  cout<<"Extend an item"<<endl;
		  break;
	   case 3:
			   cout<<"Return an item"<<endl;
		   void submit(int user);
		  break;
	   case 4:
		   exit(0);  
	   default:
		   cout<<"Please enter a correct option";
		   //continue;
	 }
   void  verification(char user,char password);

   return 0;
}


char borrow(int user)
{

   char data[80];
   ofstream outfile;
   char inLine[500];
//   char fname[20];
   char abc = 'abc';
   ifstream inFile;
   cout<<user;
   outfile.open("C:\\TC\\BIN\\Try.txt",ios::app,ios::out);
   if(!inFile.fail())
		  {
		while(!inFile.eof())
		{
			inFile>>inLine;
			if(inLine=="item_id")
		 {
			cin>>abc;
		 }
		 cout<<inLine<<endl;
		}

   cout<<"Writing to the file"<<endl;
   cout<<"enter your data:\t";
   cin.getline(data,80);
   outfile<<data<<endl;
   cout<<"Enter the class name:\t";
   cin>>data;
   cin.ignore();
   outfile<<data<<endl;
   outfile.close();

		  char inLine[500];
//		  char fname[20];
		  ifstream inFile;
		  inFile.open("C:\\TC\\BIN\\Try.txt",ios::in);

		  if(!inFile.fail())
		  {
		while(!inFile.eof())
		{
		 inFile>>inLine;
		 cout<<inLine<<endl;
		}
		   inFile.close();
		  }else
		   cout<<"Error opening File";
   return 0;
}
	cout<<"you have borrowed a book successfully";

  /*
   int c=1;
   file fp;
   fp=fopen("filename.dat","rb+");
   long recsize;
   recsize=sizeof(B);
   rewind(fp);
   clrscr();
   gotoxy(3,4);cprintf("	[Books]		");
   gotoxy(2,7);cout<<"book_no.	Book_name	Author	Publication	Price";

   gotoxy(2,8);cout<<"----------------------------------------------------------";
   while(fread(&b,resize,1,fp)==1)
   {
	cprintf("	[BOOKS]		");


   }
	*/
	return 0;
}
void submit(int user)
{
  cout<<user<<endl;
}
void extend(int user)
{
	cout<<user<<endl;
}



Hope this helps
Kevin

This post has been edited by deery5000: 24 May 2009 - 04:47 AM

Was This Post Helpful? 0
  • +
  • -

#7 shivanigandhi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 24-May 09

Re: How to fix this error..

Posted 24 May 2009 - 04:55 AM

Thank You kevin. For helping me remove all errors.
yes this is my first code and first assignment from college. may be i donot know even the basics properly..
really thankful for your life.

View Postdeery5000, on 24 May, 2009 - 03:42 AM, said:

this is working now

need file to read from
// DIC help file.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


#include<iostream>
#include "windows.h"
#include<fstream>

using namespace std;


int main()
{
	//user uobj;
	int choice;
	char user[7];
	char password[8];
	char inLine[40][80]; 
	// char borrowed[50];
	// char fname[20];
	char issue='I';
	char item_id[6];
	ifstream inFile;
	cout<<"\n Welcome to Magenta Library\n";
	cout<<"PLease Enter Your User Name";
	cin>>user;
	cout<<"Please Enter your Password";
	cin>>password;

	 cout<<"Your user name is\t"<<user<<endl;
	 cout<<"Your Password is\t"<<password<<endl;
	
	 cout<<"\n**************Welcome to MAGENTA LIBRARY************"<<endl;
	 cout<<"\nPlease enter the operation you wish to perform from the menu"<<endl;
	 cout<<"\n 1. Borrow an ITEM"<<endl;
	 cout<<"\n 2. Extend an ITEM"<<endl;
	 cout<<"\n 3. Return an ITEM"<<endl;
	 cout<<"\n 4. Exit from the system"<<endl;
	 cin>>choice;
	
	 system("cls");
	 switch(choice)
	 {
	   case 1:
		  cout<<"Borrows an item"<<endl;

		  
		  cout<<user;
		  cout<<"\n********Please select the item you wish to borrow********"<<endl;
		  

		loop1:
		cout<<"Please enter the Item_id";
		cin>>item_id;

			inFile.open("C:\\TC\\BIN\\Try.txt",ios::in);

			if(!inFile.fail())
			{
				while(!inFile.eof())
				{
					for(int i=0;i<=sizeof(inLine);i++)
					{
					  for(int j=0;j<=5;j++)
					  {
						if(inLine[i][j]==item_id[j])
						{
							if(inLine[i][5]==item_id[5])
							{
									inLine[i][75]=issue;
									inFile>>issue;
									cout<<inLine;
									inFile.close();

							}
							else
							{
								cout<<"Please enter the correct Item_id";
								goto loop1;
							}
						}	  


					  }
					   }
				}
				   

			}else
				cout<<"Error opening File";
			cout<<"\nPlease Enter the Book Id you wish to Borrow";
			cin>>item_id;
			
			cout<<"Item you have borrowed is"<<item_id;
			break;	  
	   case 2:
		  void extend(int user);
		  cout<<"Extend an item"<<endl;
		  break;
	   case 3:
			   cout<<"Return an item"<<endl;
		   void submit(int user);
		  break;
	   case 4:
		   exit(0);  
	   default:
		   cout<<"Please enter a correct option";
		   //continue;
	 }
   void  verification(char user,char password);

   return 0;
}


char borrow(int user)
{

   char data[80];
   ofstream outfile;
   char inLine[500];
//   char fname[20];
   char abc = 'abc';
   ifstream inFile;
   cout<<user;
   outfile.open("C:\\TC\\BIN\\Try.txt",ios::app,ios::out);
   if(!inFile.fail())
		  {
		while(!inFile.eof())
		{
			inFile>>inLine;
			if(inLine=="item_id")
		 {
			cin>>abc;
		 }
		 cout<<inLine<<endl;
		}

   cout<<"Writing to the file"<<endl;
   cout<<"enter your data:\t";
   cin.getline(data,80);
   outfile<<data<<endl;
   cout<<"Enter the class name:\t";
   cin>>data;
   cin.ignore();
   outfile<<data<<endl;
   outfile.close();

		  char inLine[500];
//		  char fname[20];
		  ifstream inFile;
		  inFile.open("C:\\TC\\BIN\\Try.txt",ios::in);

		  if(!inFile.fail())
		  {
		while(!inFile.eof())
		{
		 inFile>>inLine;
		 cout<<inLine<<endl;
		}
		   inFile.close();
		  }else
		   cout<<"Error opening File";
   return 0;
}
	cout<<"you have borrowed a book successfully";

  /*
   int c=1;
   file fp;
   fp=fopen("filename.dat","rb+");
   long recsize;
   recsize=sizeof(B);
   rewind(fp);
   clrscr();
   gotoxy(3,4);cprintf("	[Books]		");
   gotoxy(2,7);cout<<"book_no.	Book_name	Author	Publication	Price";

   gotoxy(2,8);cout<<"----------------------------------------------------------";
   while(fread(&b,resize,1,fp)==1)
   {
	cprintf("	[BOOKS]		");


   }
	*/
	return 0;
}
void submit(int user)
{
  cout<<user<<endl;
}
void extend(int user)
{
	cout<<user<<endl;
}



Hope this helps
Kevin



Also i would like to know what was the error that i made.

View Postshivanigandhi, on 24 May, 2009 - 03:54 AM, said:

Thank You kevin. For helping me remove all errors.
yes this is my first code and first assignment from college. may be i donot know even the basics properly..
really thankful for your life.

View Postdeery5000, on 24 May, 2009 - 03:42 AM, said:

this is working now

need file to read from
// DIC help file.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


#include<iostream>
#include "windows.h"
#include<fstream>

using namespace std;


int main()
{
	//user uobj;
	int choice;
	char user[7];
	char password[8];
	char inLine[40][80]; 
	// char borrowed[50];
	// char fname[20];
	char issue='I';
	char item_id[6];
	ifstream inFile;
	cout<<"\n Welcome to Magenta Library\n";
	cout<<"PLease Enter Your User Name";
	cin>>user;
	cout<<"Please Enter your Password";
	cin>>password;

	 cout<<"Your user name is\t"<<user<<endl;
	 cout<<"Your Password is\t"<<password<<endl;
	
	 cout<<"\n**************Welcome to MAGENTA LIBRARY************"<<endl;
	 cout<<"\nPlease enter the operation you wish to perform from the menu"<<endl;
	 cout<<"\n 1. Borrow an ITEM"<<endl;
	 cout<<"\n 2. Extend an ITEM"<<endl;
	 cout<<"\n 3. Return an ITEM"<<endl;
	 cout<<"\n 4. Exit from the system"<<endl;
	 cin>>choice;
	
	 system("cls");
	 switch(choice)
	 {
	   case 1:
		  cout<<"Borrows an item"<<endl;

		  
		  cout<<user;
		  cout<<"\n********Please select the item you wish to borrow********"<<endl;
		  

		loop1:
		cout<<"Please enter the Item_id";
		cin>>item_id;

			inFile.open("C:\\TC\\BIN\\Try.txt",ios::in);

			if(!inFile.fail())
			{
				while(!inFile.eof())
				{
					for(int i=0;i<=sizeof(inLine);i++)
					{
					  for(int j=0;j<=5;j++)
					  {
						if(inLine[i][j]==item_id[j])
						{
							if(inLine[i][5]==item_id[5])
							{
									inLine[i][75]=issue;
									inFile>>issue;
									cout<<inLine;
									inFile.close();

							}
							else
							{
								cout<<"Please enter the correct Item_id";
								goto loop1;
							}
						}	  


					  }
					   }
				}
				   

			}else
				cout<<"Error opening File";
			cout<<"\nPlease Enter the Book Id you wish to Borrow";
			cin>>item_id;
			
			cout<<"Item you have borrowed is"<<item_id;
			break;	  
	   case 2:
		  void extend(int user);
		  cout<<"Extend an item"<<endl;
		  break;
	   case 3:
			   cout<<"Return an item"<<endl;
		   void submit(int user);
		  break;
	   case 4:
		   exit(0);  
	   default:
		   cout<<"Please enter a correct option";
		   //continue;
	 }
   void  verification(char user,char password);

   return 0;
}


char borrow(int user)
{

   char data[80];
   ofstream outfile;
   char inLine[500];
//   char fname[20];
   char abc = 'abc';
   ifstream inFile;
   cout<<user;
   outfile.open("C:\\TC\\BIN\\Try.txt",ios::app,ios::out);
   if(!inFile.fail())
		  {
		while(!inFile.eof())
		{
			inFile>>inLine;
			if(inLine=="item_id")
		 {
			cin>>abc;
		 }
		 cout<<inLine<<endl;
		}

   cout<<"Writing to the file"<<endl;
   cout<<"enter your data:\t";
   cin.getline(data,80);
   outfile<<data<<endl;
   cout<<"Enter the class name:\t";
   cin>>data;
   cin.ignore();
   outfile<<data<<endl;
   outfile.close();

		  char inLine[500];
//		  char fname[20];
		  ifstream inFile;
		  inFile.open("C:\\TC\\BIN\\Try.txt",ios::in);

		  if(!inFile.fail())
		  {
		while(!inFile.eof())
		{
		 inFile>>inLine;
		 cout<<inLine<<endl;
		}
		   inFile.close();
		  }else
		   cout<<"Error opening File";
   return 0;
}
	cout<<"you have borrowed a book successfully";

  /*
   int c=1;
   file fp;
   fp=fopen("filename.dat","rb+");
   long recsize;
   recsize=sizeof(B);
   rewind(fp);
   clrscr();
   gotoxy(3,4);cprintf("	[Books]		");
   gotoxy(2,7);cout<<"book_no.	Book_name	Author	Publication	Price";

   gotoxy(2,8);cout<<"----------------------------------------------------------";
   while(fread(&b,resize,1,fp)==1)
   {
	cprintf("	[BOOKS]		");


   }
	*/
	return 0;
}
void submit(int user)
{
  cout<<user<<endl;
}
void extend(int user)
{
	cout<<user<<endl;
}



Hope this helps
Kevin

Was This Post Helpful? 0
  • +
  • -

#8 deery5000  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 966
  • Joined: 09-May 09

Re: How to fix this error..

Posted 24 May 2009 - 05:11 AM

i had to change your header files. i think there the C method and not c++.

i included "windows.h" so i could use system("cls"); to clear the screen

main should not be void but "int"

declared a variable abc cause complier didnt like cin >> 'abc';
char abc = 'abc'
cin>>abc;

only minor changes but solved the problem :)

Kevin
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1