- #include<iostream>
-
#include<iomanip>
-
#include<fstream>
-
using namespace std;
-
-
-
-
struct info_struct
-
{
-
char ID[5];
-
int number_year;
-
int number_CD;
-
};
-
-
-
-
void Display(info_struct[], int);
-
void Passing(info_struct[], int);
-
-
int main()
-
{
-
char select;
-
cout << setprecision(2)
-
<< setiosflags(ios::fixed)
-
<< setiosflags(ios::showpoint);
-
-
-
-
info_struct info[4] =
-
{{"M123" , 2, 3},
-
{"M225", 1, 6},
-
{"M248", 2, 1},
-
{"M552", 3, 5}};
-
do
-
{
-
-
cout << "Mr. Muzik's Fanatastic Music Club\n";
-
cout << "==================================\n";
-
cout << "A - Display Annual Report\n";
-
cout << "B - Input Information\n";
-
cout << "Please make a selection: ";
-
cin >> select;
-
-
switch(select)
-
{
-
case 'A':
-
case 'a':
-
-
-
Display(info, 4);
-
-
break;
-
-
Passing(info, 4);
-
-
case 'B':
-
case 'b':
-
-
-
break;
-
default:
-
cout << endl << endl
-
<< "Invalid Property Code! Try again.\n" << endl;
-
break;
-
-
-
}
-
}while((select != 'a' || select != 'A') && (select != 'B' || select != 'b'));
-
return 0;
-
}
-
-
-
void Display(info_struct NEW[], int size)
-
{
-
int i;
-
cout << endl << endl;
-
cout << setw(20)<< "ID"
-
<< setw(20) << "Number of Year"
-
<< setw(20) << "Number of CD bought" << endl;
-
-
for (i = 0; i < size; ++i)
-
{
-
cout << endl;
-
cout << setw(20)<< NEW[i].ID
-
<< setw(20)<< NEW[i].number_year
-
<< setw(20)<< NEW[i].number_CD << endl;
-
}
-
}
-
void Passing(info_struct NEW_2, int size_2)
-
-
{
-
int row;
-
-
cout << endl;
-
cout << "Enter the table values: "
-
<<endl << endl;
-
for(row = 0; row < size_2; ++row)
-
{
-
cout << endl;
-
-
cout << "ID Number: ";
-
cin.getline(NEW_2[row].ID, 5);
-
-
cout << "Number of Year: ";
-
cin >> NEW_2[row].number_year;
-
-
cout << "Number of CD bought: ";
-
cin >> NEW_2[row].number_CD;
-
-
cin.get();
-
}
-
}
I am a bit confused on why it doesnt work I am trying to have it enter the information, from the void. I guess I want to make the stucture interactive inside or outside the main?
4 1372 Savage 1,764
Recognized Expert Top Contributor
What errors are you getting?
Also take a good look at this: - case 'A':
-
case 'a':
-
-
Display(info, 4);
-
break;
-
-
Passing(info, 4);
-
-
case 'B':
-
case 'b':
And please use code tags around your code.(Select your code and press # button,you can also specify a language e.g[code=C] will use C markings)
Savage
Thanks a whole bunch I was just curious:
On my passing structure whenever the user types in more then 2 values the whole program loops: -
void Passing(info_struct NEW_2[], int size_2)
-
-
{
-
int row;
-
cout << endl;
-
cout << "Enter the table values: "
-
<< endl << endl;
-
for(row = 0; row < size_2; ++row)
-
{
-
cout << endl;
-
-
cout << "ID Number: ";
-
cin.getline(NEW_2[row].ID, 4);
-
-
cout << "Number of Year: ";
-
cin >> NEW_2[row].number_year;
-
-
cout << "Number of CD bought: ";
-
cin >> NEW_2[row].number_CD;
-
-
cin.get();
-
}
-
}
-
I hope I placed in the code tags right. I thought if I had that number 4 it wouldnt matter. I try adding a do while but it ended looping the number of year and CD I am still working on it I just wish I knew what I should do.
Savage 1,764
Recognized Expert Top Contributor
I believe that solution to your problem lies in this thread
I believe that solution to your problem lies in this thread
Thank you for your help and patience
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Siddharth Taneja |
last post by:
Hi,
I have a very simple prg over here, trying to read the lines of a file
#include <iostream>
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
|
by: gnv |
last post by:
Hi all,
I am writing a cross-browser(i.e. 6 and netscape 7.1) javascript
program to save an XML file to local file system.
I have an xml string like below:
var xmlStr = "<?xml version="1.0"...
|
by: Johnny Google |
last post by:
Here is an example of the type of data from a file I will have:
Apple,4322,3435,4653,6543,4652
Banana,6934,5423,6753,6531
Carrot,3454,4534,3434,1111,9120,5453
Cheese,4411,5522,6622,6641
The...
|
by: Sky Sigal |
last post by:
I have created an IHttpHandler that waits for uploads as attachments for a
webmail interface, and saves it to a directory that is defined in
config.xml.
My question is the following:
assuming...
|
by: Daniel Corbett |
last post by:
I am trying to save a file dynamically created in a webpage. I get the
following headers, but cannot figure out how to save the attachment. I am
basically trying to replicate what internet...
| |
by: IcingDeath via DotNetMonster.com |
last post by:
I am building this SQL Server database app in which i can store files. In
order to display files I want to have the app show the associated icon for
the extension of the file that is in the...
|
by: rony_16 |
last post by:
Hi,
I have a program that connects to a site With WebRequest and
WebResponse .
The response of this site is a file (csv file).
The problem is that the file do not comes as a stream , hi is a part...
|
by: AdrianH |
last post by:
Assumptions
I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming.
FYI
Although I have called...
|
by: J055 |
last post by:
Hi
I have the following code. I upload an XML file using the FileUpload object,
store the stream in a session so the user gets the chance to confirm some
options then pass the stream from the...
|
by: Dennis |
last post by:
Hi, I have a text file that contents a list of email addresses like
this:
"foo@yahoo.com"
"tom@hotmail.com"
"jerry@gmail.com"
"tommy@apple.com"
I like to
|
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,...
| |
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,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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: 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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 ...
|
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...
| |