- #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 1375 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" encoding="UTF-8"?><a>some info</a>";
I want to save this xml file to local file system with JavaScript,
|
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 first position is the info (the product) I want to retreive for the
corresponding code. Assuming that the codes are unique for each product
and all...
|
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 that this is suppossed to end up as a component for others to use,
and therefore I do NOT have access to their global.cs::Session_End()
how do I...
|
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 explorer would do in this case.
The headers I am getting are:
Headers {Content-Disposition: attachment; filename="dynamic_file.mdb"
Connection:...
| |
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 database. Therefore the file doesnt
really exist on the user's hard drive. All the file extracting techniques
require that I have the actual file on 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 of
the header
(Content-Disposition:attachment; filename=changehistory.csv)
i tried to download this file as a stream , but it do not work .
i...
|
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 this article “How to Parse a File in C++”, we are actually mostly lexing a file which is the breaking down of a stream in to its component parts,...
|
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 Session to an XmlReader.
if (performImport == false)
{
Session = fileUpload1.FileContent;
//... some other code
|
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, 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...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |