Error occur in the program.

This is a discussion on Error occur in the program. within the C++ Programming forums, part of the General Programming Boards category; When the program execute, there will an error occur. If put a "break" after the tra[i].displayTran(), the program cannot display ...

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    7

    Error occur in the program.

    When the program execute, there will an error occur.
    If put a "break" after the tra[i].displayTran(), the program cannot display all the transaction record.
    How to solve the problem?

    Code:
    case 'T':
    			acctType=men.typeMenu();
    			if(acctType=='C')
    			{
    				int acNo;
    				system("cls");
    				r.open("transaction.txt");
    				cout<<"\nTransaction done";
    				cout<<"\nEnter your checking account number: ";
    				cin>>acNo;
    				for(int i=0;!r.eof()+1;i++)
    				{
    					r.read((char*)(&tra[i]),sizeof(tra[i]));
    					if(acNo==tra[i].getacctNum())
    					{			
    						tra[i].displayTran();
    					}
    				}
    				r.close();				
    				break;
    			}
    			if(acctType=='S')
    			{
    				sav[n].deposit();
    				break;
    			}
    			else
    			{
    				cout<<"Invalid type";
    				cout<<"\n\nPress ENTER to continue...";
    				while(!cin.get()){};
    				while(!cin.get()){};
    			}						break;

  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Can you define your problem a little better? I don't quite understand what is going wrong.

  3. #3
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,161

    Re: Error occur in the program.

    Originally posted by nasa
    How to solve the problem?
    By explaining in detail. "An error" could be 20 things. What error.

    It's OK to edit tabs to spaces when you post your code so your post is not so wide.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,823
    > for(int i=0;!r.eof()+1;i++)
    What exactly is !r.eof()+1 supposed to do?

    And no, chopping a lump out of your code from here and posting it as another thread doesn't really count. We much prefer to see a complete program which demonstrates a problem. Random snippets like this may well work perfectly in isolation, but are killed by a wider problem which isn't shown.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21