473,796 Members | 2,740 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

need immediate help with struct !

3 New Member
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_st ructure [25][25]' to 'Transaction_st ructure *'
error C2664: 'transact' : cannot convert parameter 1 from 'Transaction_st ructure [25]' to 'Transaction_st ructure &'
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_str ucture {
int amt;
char trans_desc[25];
};

const int ARRAYSIZE = 25 ;

int display_menu ();
double transact ( Transaction_str ucture & , char [] );
void transaction_his tory ( const double [],
const char [][ ARRAYSIZE ],
const double,
const int,
const Transaction_str ucture *
);

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_str ucture 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_his tory ( 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_str ucture &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 << "Transactio n recorded.\n\n";
}
else
cout << "*** Zero entered. No transaction will be recorded.\n\n";

return amt;
}

void transaction_his tory ( const double trnx_amt[],
const char trans_desc [] [ ARRAYSIZE ],
const double cur_bal,
const int cur_trnx,
const Transaction_str ucture *tran
)
{
double payments = 0.0,
refunds = 0.0;

cout << "Transactio n 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 1162

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

Similar topics

4
6351
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 method would behave like the 'findnodes' XML method in Perl. Namely that you can pass it an xpath statement and it will find nodes that match: $array = $node->get_elements_by_tagname($xpath); This is long so here's a pagebreak: And, indeed,...
2
2870
by: aj902 | last post by:
Hello , I am trying to create a program where all detail, http://www.albany.edu/~csi333/projects.htm
2
12832
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
3437
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 I can find it. Also, is there a trick now to single step. I can't find that anywhere either. Thanks Russ Stevens
66
5420
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 occurs. After the program has read the file, it should offer a menu with three choices. the first is to list all the words along with the number of occurences. The second is to let you enter a word, with the program reporting how many times the...
21
3227
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 (i.e. the get_hash function) is borrowed from various snippets I found on the net. Thee free function could probably need some love. I have been thinking about having a second linked list of all entries so that the cost of freeing is in proportion to...
2
2597
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 of ok but doesn't have intellisense. Documentation shows that editions above Express do have immediate windows. We've looked under Debug, View, and just about everywhere else. I don't see the Immediate window under View on my system either,...
6
2842
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 your cursor was somewhere in the middle of the text output, then there would be no scrolling. In VS2005, the Immediate Window scrolls regardless of where the cursor is which is very annoying. Sometimes you want to go back up in the window to...
4
3093
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 execute MsgBox(DateTime.Now.Kind)
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10244
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9061
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7558
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5454
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4130
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2931
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.