473,397 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

need immediate help with struct !

Hi,
I am getting 2 errors when i try to run my program. This is my first time using the struct feature so i'm not sure how to correct my errors. Any help will be greatly appreciated.
Here are the errors i am getting :
error C2440: 'initializing' : cannot convert from 'Transaction_structure [25][25]' to 'Transaction_structure *'
error C2664: 'transact' : cannot convert parameter 1 from 'Transaction_structure [25]' to 'Transaction_structure &'
A reference that is not to 'const' cannot be bound to a non-lvalue
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <cstring>

struct Transaction_structure {
int amt;
char trans_desc[25];
};

const int ARRAYSIZE = 25 ;

int display_menu ();
double transact ( Transaction_structure & , char [] );
void transaction_history ( const double [],
const char [][ ARRAYSIZE ],
const double,
const int,
const Transaction_structure *
);

void main()
{

double trnx_amt [ ARRAYSIZE ] = { 0.0 }, // stores the amount of the transaction
cur_bal = 0.0;

int cur_trnx = 0, // use as index into arrays; skipping index 0)
menu_choice = 0;

char desc [ ARRAYSIZE ] [ ARRAYSIZE ] = { 0 } ; // 2-d array for transaction descriptions
Transaction_structure transaction [ARRAYSIZE][ARRAYSIZE] = {0},
*show = transaction;
for ( int i = 0; i < ARRAYSIZE; i++ )


cout << "Point of Sale Program\n"
<< "-----------------\n\n" ;

while ( cur_trnx < ARRAYSIZE && ( menu_choice = display_menu () ) )
{
switch ( menu_choice )
{
case 1:
for ( int i = 0; i < ARRAYSIZE; i++ )
if ( trnx_amt [ cur_trnx ] = transact (transaction[i], transaction [ cur_trnx ] ) )
{
cur_bal += trnx_amt [ cur_trnx ] ;
cur_trnx++ ;
}
break ;
case 2:
transaction_history ( trnx_amt, desc, cur_bal, cur_trnx, show );
break ;

default:
cout << "\nInvalid selection, please choose again.\n" ;
}

}

cout << "Closing Account...\n\n";

cout << "\n*** End of Program ***\n" << endl ;

}

int display_menu ()
{
int choice;

cout << "1. Enter a Transaction\n"
<< "2. Transaction History\n\n"
<< "0. Exit Program\n\n"
<< "Please enter your selection: ";
cin >> choice ;
return choice;
}

double transact ( Transaction_structure &tran, char trans_desc [] )
{
double amt;

cout << "\nPlease enter the amount of the transaction. Enter a positive number for\n"
<< "a sale and a negative number if a refund: " ;
cin >> tran.amt;

if ( amt )
{
cout << "\nPlease enter a one-word description of the item sold/returned: " ;
cin >> tran.trans_desc ;
cout << "Transaction recorded.\n\n";
}
else
cout << "*** Zero entered. No transaction will be recorded.\n\n";

return amt;
}

void transaction_history ( const double trnx_amt[],
const char trans_desc [] [ ARRAYSIZE ],
const double cur_bal,
const int cur_trnx,
const Transaction_structure *tran
)
{
double payments = 0.0,
refunds = 0.0;

cout << "Transaction History\n"
<< "-------------------\n\n" ;

for ( int i = 0; i < cur_trnx; i++ )
{
cout << i + 1 << ". " ;
if ( trnx_amt [ i ] > 0 )

{
cout << "Sale of " << trans_desc [i] << ": $" << trnx_amt [ i ] << "\n";
payments += trnx_amt [ i ];
}
else
{
cout << "Refund for " << trans_desc [i] << ": $" << -trnx_amt [ i ] << "\n";
refunds += -trnx_amt [ i ];
}


}
cout << "\n--------------------------------" ;
cout << "\nTotal sales : $" << payments ;
cout << "\nTotal refunds: ($" << refunds << ")" ;
cout << "\nNet : $" << cur_bal
<< "\n--------------------------------\n\n" ;
}
Nov 16 '06 #1
0 1135

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: MegaZone | last post by:
I'm having some issues with PHP DOMXML - in particular the get_elements_by_tagname method. Now, the PGP docs on this are, well, sparse, so maybe I'm just doing something stupid. I thought this...
2
by: aj902 | last post by:
Hello , I am trying to create a program where all detail, http://www.albany.edu/~csi333/projects.htm
2
by: Jon Davis | last post by:
How do I get the Immediate window back? It seems to be gone. Command window doesn't work. "View" menu items don't seem to show it Jon
3
by: Russell Stevens | last post by:
Can anyone tell me how to get to the immediate window in VS2005. The help file says (when debugging) to click Debug, Windows, Immediate. There is no Immediate window listed there, nor anywhere else...
66
by: genestarwing | last post by:
QUESTION: Write a program that opens and read a text file and records how many times each word occurs in the file. Use a binary search tree modified to store both a word and the number of times it...
21
by: Johan Tibell | last post by:
I would be grateful if someone had a minute or two to review my hash table implementation. It's not yet commented but hopefully it's short and idiomatic enough to be readable. Some of the code...
2
by: dgk | last post by:
Using VS2005 Standard Edtion, I have an Immediate window during ASP debugging. My co-worker, using VS2005 Team Edtion does not have an Immediate window. He does have a Command window, which is sort...
6
by: Frank Rizzo | last post by:
I am using the Immediate Window a lot to see the progress of the application. In VS2003, if your cursor was at the very bottom, the window would scroll down whenever something new showed up. If...
4
by: Armin Zingler | last post by:
Hi, I feel fooled.. In the immediate window, if I enter ? DateTime.Now.Kind I get "Unspecified {0}". The result - I expected "local" - lead to some time consuming deliberations. Today, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.