473,385 Members | 1,569 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,385 software developers and data experts.

New Programmer

AKF
I have a program that requires being able to read in a file, add a new
item to the file and to delete an item from the file. How do I now
implement it using an array?

/*Declare header files to be used in the program*/
#include<iostream.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
//Declaring structures to be used in the program
struct Stock_Item;
struct Bill;
struct Bill_Item;
struct Stock;

struct Stock_Item //Function prototype for a Stock data type
{
int code;
char description[25];
float price;
};

struct Stock
{
Stock_Item si[20];
int nStock_Item;
};

struct Bill_Item //Function prototype for a Bill_Item data type
{
int code;
char description[25];
float weight;
float cost;
};

struct Bill //Function prototype for a Bill data type
{
Bill_Item bi[20];
int nitems;
};
//Function Prototypes available to the data structure
void add_Bill_Item(Bill_Item& bi, int* code, char* desc, float* w,
float* c);
void add_Stock_Item (Stock_Item& si, int* code, char* desc, float* c);
void display_Bill_Item(Bill_Item bi);
void display_Stock_Item(Stock_Item si);
void create_Stock_Item(Stock_Item& si);
void create_Stock(Stock& s);
//Setting stock_Item

void add_Stock_Item(Stock_Item& si, int code, char desc, float p)
{
cout << "Enter a code:";
cin >> si.code;
cout << "Enter a description:";
cin >> si.description;
cout << "Enter a price:";
cin >> si.price;
}

//Display Stock_Item structure operations
void display_Stock_Item(Stock_Item si)
{
cout << si.code << si.description << si.price <<endl;
}
//Setting Bill_Item

void add_Bill_Item(Bill_Item& bi)

{
cout << "Enter a code:";
cin >> bi.code;
cout << "Enter a description:";
cin >> bi.description;
cout << "Enter a weight:";
cin >> bi.weight;
cout << "Enter a cost:";
cin >> bi.cost;
}
//Display Bill_Item Structure Operations
void display_Bill_Item(Bill_Item bi)
{
cout << bi.code << bi.description << bi.weight <<bi.cost <<endl;
}


//*****************THE ACTUAL PROGRAM STARTS HERE**************

void main()
{

}
Jul 22 '05 #1
1 1140
>I have a program that requires being able to read in a file, add a new
item to the file and to delete an item from the file. How do I now
implement it using an array?

/*Declare header files to be used in the program*/
#include<iostream.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
//Declaring structures to be used in the program
struct Stock_Item;
struct Bill;
struct Bill_Item;
struct Stock;

struct Stock_Item //Function prototype for a Stock data type
{
int code;
char description[25];
float price;
};

struct Stock
{
Stock_Item si[20];
int nStock_Item;
};

struct Bill_Item //Function prototype for a Bill_Item data type
{
int code;
char description[25];
float weight;
float cost;
};

struct Bill //Function prototype for a Bill data type
{
Bill_Item bi[20];
int nitems;
};
//Function Prototypes available to the data structure
void add_Bill_Item(Bill_Item& bi, int* code, char* desc, float* w,
float* c);
void add_Stock_Item (Stock_Item& si, int* code, char* desc, float* c);
void display_Bill_Item(Bill_Item bi);
void display_Stock_Item(Stock_Item si);
void create_Stock_Item(Stock_Item& si);
void create_Stock(Stock& s);
//Setting stock_Item

void add_Stock_Item(Stock_Item& si, int code, char desc, float p)
{
cout << "Enter a code:";
cin >> si.code;
cout << "Enter a description:";
cin >> si.description;
cout << "Enter a price:";
cin >> si.price;
}

//Display Stock_Item structure operations
void display_Stock_Item(Stock_Item si)
{
cout << si.code << si.description << si.price <<endl;
}
//Setting Bill_Item

void add_Bill_Item(Bill_Item& bi)

{
cout << "Enter a code:";
cin >> bi.code;
cout << "Enter a description:";
cin >> bi.description;
cout << "Enter a weight:";
cin >> bi.weight;
cout << "Enter a cost:";
cin >> bi.cost;
}
//Display Bill_Item Structure Operations
void display_Bill_Item(Bill_Item bi)
{
cout << bi.code << bi.description << bi.weight <<bi.cost <<endl;
}


//*****************THE ACTUAL PROGRAM STARTS HERE**************

void main()
{

}


Your question is very unclear. From your first 3 lines of text, I thought you
were seeking advice on textfile processing and doing the same task using an
array, but from the additional code you've written, it looks like you want
someone to write the application for you. Which is it? If it's the advice, then
please restate the question and stick to the issue.
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Daniel Chartier | last post by:
Hello. I work in the paper industry and we recently had someone (the original author) from within the company make a program for preventive maintenance. However, it had some bugs and we wanted...
11
by: | last post by:
What do I do? Any ideas? I went back to school after many years and finished my bachelors degree and studied programming at a local tech school. I have no great talent to return to (mainframe...
0
by: Christian McArdle | last post by:
REQUEST FOR DISCUSSION (RFD) unmoderated group comp.os.ms-windows.programmer.win64 This is a formal Request For Discussion (RFD) to create comp.os.ms-windows.programmer.win64 as an unmoderated...
0
by: Christian McArdle | last post by:
REQUEST FOR DISCUSSION (RFD) unmoderated group comp.os.ms-windows.programmer.win64 This is a formal Request For Discussion (RFD) to create comp.os.ms-windows.programmer.win64 as an unmoderated...
3
by: Christian McArdle | last post by:
REQUEST FOR DISCUSSION (RFD) unmoderated group comp.os.ms-windows.programmer.64bit This is a formal Request For Discussion (RFD) to create comp.os.ms-windows.programmer.64bit as an unmoderated...
29
by: jeffc | last post by:
How would you answer a question like this in an interview? I'm not interested in gathering the average of folks on this forum. I'm interested in a strategy for a) evaluating yourself objectively...
5
by: jrefactors | last post by:
when people say unix programmer, does it mean they write programs in unix environment,and those programs are run in unix platform? it is not necessary they are using unix function calls? I heard...
72
by: E. Robert Tisdale | last post by:
What makes a good C/C++ programmer? Would you be surprised if I told you that it has almost nothing to do with your knowledge of C or C++? There isn't much difference in productivity, for...
23
by: Steve Jorgensen | last post by:
Hi all, I'm working on a project through a consulting company, and I'm writing some database code for use in another programmer's project in Excel/VBA. The other programmer is working through...
13
by: BK | last post by:
Our .Net team has just inherited a junior programmer that we need to get up to speed as quickly as possible. Unfortunately, his skill set is largely Access with some VB6 and ASP classic...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.