HAVING ERRORS

IAM HAVING LOTS OF ERRORS

Page 1 of 1

1 Replies - 400 Views - Last Post: 26 December 2008 - 01:45 PM Rate Topic: -----

#1 seismic  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 26-December 08

HAVING ERRORS

Post icon  Posted 26 December 2008 - 01:32 PM

#include <iostream.h>
#include <stdlib.h>
#include <fstream.h>
#include <iomanip.h>

void searchAccountDisplay ( int );
void searchNameDisplay ( char * );
void searchTypeDisplay ( char * );
void line ();
void numbering ( int );
int main ()
{

	struct dataAcc
	{   int data;
	int found;
	int Number;
	char HolderName[];
	char Type[];
	double Balance;
	};
	dataAcc data [5];
	int choice,adata, userAnumber, found = 0;

	fstream outInfoFile ( "Info.txt", ios::out );

	if ( !outInfoFile )
	{
	cerr << "The file \"Info.txt is not created. \" " << endl;
	exit (1);
	}
	for ( int i = 0; i < 3; i ++ )
	{
	numbering ( i );
	cout << i + 1 << "Please enter your Account Number:  "<<endl;
	cin >> data[i].Number;
	cout << "Please enter your Name:  "<<endl;
	cin >> data[i].HolderName;
	cout << "Please enter account type:  "<<endl;
	cin >> data[i].Type;
	cout << "Please enter your Account Balance:  "<<endl;
	cin >> data[i].Balance;

	outInfoFile << setw (12) << data[i].Number<< setw (12)
	<< data[i].HolderName << setw (12) << data[i].Type << setw (12)
	<< data[i].Balance << endl;
	}

	line ();

	cout << "Enter 1 to search account information by Account number" << endl
	<< "Enter 2 to search account information by Account holder name" << endl
	<< "Enter 3 to search number of user having particular Account type" << endl
	<< "Enter 4 to search number of user having Account balance greater than 10,000" << endl
	<< "Enter 5 to quit from program." << endl;
	cin >> choice;
	switch ( choice )
	{
	case 1:
	cout << "Please enter your account number. "<< endl;
	cin >> userAnumber;
	searchAccountDisplay ( userAnumber );
	break;

}

	return 0;
}

void line ()
{
	int k;
	cout << "\n\n\t";
	for ( k = 0; k < 60; k ++ )
	{
	cout << "\xDB";
	}
	cout << endl << endl;
}

void numbering ( int x )
{
	switch ( x )
	{
		case 0:
		cout << "You are 1st Clien giving your information.";
		break;

		case 1:
		cout << "nYou are 2nd Clien giving your information.";
		break;

		case 2:
		cout << "You are third Clien giving your information.";
		break;

		default:
		cout << "You are " << x << "th Clien giving your information.";
		break;
	}
}

void searchAccountDisplay ( int num )
{
	int j;
	for ( j = 0; j < 3; j ++ )
	{
	if ( num == data[j].Number )
	found = 1;
		break;
	}
	if ( found == 1 )

	{
	cout << "Your name is: " << data[j].HolderName << endl;
	cout << "Your account number is: " << data[j].Number << endl;
	cout << "Your account type is: "<< data[j].aType << endl;
		cout  << "Your account Balance is: "<< data[j].Balance << endl;
	}
	else
	cout << "Your account number is not found" << endl;
}
getch();



Is This A Good Question/Topic? 0
  • +

Replies To: HAVING ERRORS

#2 badjava  Icon User is offline

  • Lux Ex Tenebris
  • member icon

Reputation: 14
  • View blog
  • Posts: 540
  • Joined: 30-October 08

Re: HAVING ERRORS

Posted 26 December 2008 - 01:45 PM

View Postseismic, on 26 Dec, 2008 - 12:32 PM, said:

I'm having lots of errors


What is it you are trying to do? What errors are you having? We need some more information!

I attempted to compile your code and got an error message that the data[j] and 'found' variables being used in the sub function searchAccountDisplay( ) are undefined. It looks like you have a scope problem.

I haven't tried passing these in the function call to see if it fixes the problem but you might want to look there first.

You have a getch() outside of the final brace for this same sub function by the way. If you move that inside the braces (see your last two lines of code) that will take care of another one of your errors.

Let me know if that helps ok?

P.S. By the way, is this C rather than C++? I'm no master here but I noticed you don't have a name space declared. After moving getch() inside that last brace I get an error that looks like the proper #include isn't in your code or in the name space/scope that your sub function can recognize this built in function call. I'm no master like I mentioned but if this is C++ you have some fundamental problems you need to fix before this will work right. Have you looked at some starting templates to build you program upon? That is always helpful also. Something like this:
//
// Template 
//
// the following include files define the majority of
// functions that any given program will need
#include <cstdio>
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
//insert your main program code under here between these two sets of comments


// wait until user is ready before terminating program
// to allow the user to see the program results
system("PAUSE");
return 0;
}

This post has been edited by badjava: 26 December 2008 - 01:58 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1