SlideShare a Scribd company logo
1 of 2
Download to read offline
I have code that reads and writes sstrings to file but I am having trouble meeting these
requirements. My program writes the string names into the file and not the number of bags. I
think a for loop is needed to keep track of how many times their name is written and then check
their on board status but I'm not sure. This is the code I have
#include
#include
#include
using namespace std;
int openOutputFile();
int openInputFile();
void readInputRecord(ifstream& inpt);
void writeOutputRecord(ofstream& opt);
int count_b = 0;
int count_p = 0;
string PassengerArray[100];
string BaggageArray[300];
int main()
{
openInputFile();
openOutputFile();
system("pause");
}
void readInputRecord(ifstream& inpt)
{
string line;
int i = 0;
//read passanger from file
while (getline(inpt, line))
{
PassengerArray[i] = line;
i++;
}
cout << "Passanger Array " << endl;
for (int k = 0; k
Solution
while (getline(inpt, line) && line != "")
{
BaggageArray[i] = line;
i++;
}
count_b = i;
cout << "Baggage Array" << endl;
for (int k = 0; k

More Related Content

Similar to I have code that reads and writes sstrings to file but I am having t.pdf

So I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdfSo I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdf
ezonesolutions
 
C programming.   For this code I only need to add a function so th.pdf
C programming.   For this code I only need to add a function so th.pdfC programming.   For this code I only need to add a function so th.pdf
C programming.   For this code I only need to add a function so th.pdf
badshetoms
 
Lecture 15_Strings and Dynamic Memory Allocation.pptx
Lecture 15_Strings and  Dynamic Memory Allocation.pptxLecture 15_Strings and  Dynamic Memory Allocation.pptx
Lecture 15_Strings and Dynamic Memory Allocation.pptx
JawadTanvir
 
Unit 4
Unit 4Unit 4
Unit 4
siddr
 
C aptitude questions
C aptitude questionsC aptitude questions
C aptitude questions
Srikanth
 
C - aptitude3
C - aptitude3C - aptitude3
C - aptitude3
Srikanth
 
So basically I worked really hard on this code in my CS150 class and.pdf
So basically I worked really hard on this code in my CS150 class and.pdfSo basically I worked really hard on this code in my CS150 class and.pdf
So basically I worked really hard on this code in my CS150 class and.pdf
eyewaregallery
 
Reading and writting v2
Reading and writting v2Reading and writting v2
Reading and writting v2
ASU Online
 

Similar to I have code that reads and writes sstrings to file but I am having t.pdf (20)

So I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdfSo I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdf
 
C
CC
C
 
Programming in C
Programming in CProgramming in C
Programming in C
 
streams and files
 streams and files streams and files
streams and files
 
C programming(part 3)
C programming(part 3)C programming(part 3)
C programming(part 3)
 
Data structure week 3
Data structure week 3Data structure week 3
Data structure week 3
 
C q 3
C q 3C q 3
C q 3
 
Unit 3
Unit 3 Unit 3
Unit 3
 
C programming.   For this code I only need to add a function so th.pdf
C programming.   For this code I only need to add a function so th.pdfC programming.   For this code I only need to add a function so th.pdf
C programming.   For this code I only need to add a function so th.pdf
 
Lecture 15_Strings and Dynamic Memory Allocation.pptx
Lecture 15_Strings and  Dynamic Memory Allocation.pptxLecture 15_Strings and  Dynamic Memory Allocation.pptx
Lecture 15_Strings and Dynamic Memory Allocation.pptx
 
Static types on javascript?! Type checking approaches to ensure healthy appli...
Static types on javascript?! Type checking approaches to ensure healthy appli...Static types on javascript?! Type checking approaches to ensure healthy appli...
Static types on javascript?! Type checking approaches to ensure healthy appli...
 
Strings v.1.1
Strings v.1.1Strings v.1.1
Strings v.1.1
 
Unit 4
Unit 4Unit 4
Unit 4
 
PSI 3 Integration
PSI 3 IntegrationPSI 3 Integration
PSI 3 Integration
 
C aptitude questions
C aptitude questionsC aptitude questions
C aptitude questions
 
C - aptitude3
C - aptitude3C - aptitude3
C - aptitude3
 
Rust LDN 24 7 19 Oxidising the Command Line
Rust LDN 24 7 19 Oxidising the Command LineRust LDN 24 7 19 Oxidising the Command Line
Rust LDN 24 7 19 Oxidising the Command Line
 
So basically I worked really hard on this code in my CS150 class and.pdf
So basically I worked really hard on this code in my CS150 class and.pdfSo basically I worked really hard on this code in my CS150 class and.pdf
So basically I worked really hard on this code in my CS150 class and.pdf
 
The bones of a nice Python script
The bones of a nice Python scriptThe bones of a nice Python script
The bones of a nice Python script
 
Reading and writting v2
Reading and writting v2Reading and writting v2
Reading and writting v2
 

More from ahntagencies

LTE uses an all IP data network, with voice calls reduced to a multim.pdf
LTE uses an all IP data network, with voice calls reduced to a multim.pdfLTE uses an all IP data network, with voice calls reduced to a multim.pdf
LTE uses an all IP data network, with voice calls reduced to a multim.pdf
ahntagencies
 
I Need Serious Help with this assignment. Plenty Points to be earned.pdf
I Need Serious Help with this assignment. Plenty Points to be earned.pdfI Need Serious Help with this assignment. Plenty Points to be earned.pdf
I Need Serious Help with this assignment. Plenty Points to be earned.pdf
ahntagencies
 
Do the following program in C++- Create a item class... with and i.pdf
Do the following program in C++- Create a item class... with and i.pdfDo the following program in C++- Create a item class... with and i.pdf
Do the following program in C++- Create a item class... with and i.pdf
ahntagencies
 
Consider the following scenario A population of moderately pigmented.pdf
Consider the following scenario A population of moderately pigmented.pdfConsider the following scenario A population of moderately pigmented.pdf
Consider the following scenario A population of moderately pigmented.pdf
ahntagencies
 
Cell adhesion, both cell-cell and cell-ECM, can influence whether a c.pdf
Cell adhesion, both cell-cell and cell-ECM, can influence whether a c.pdfCell adhesion, both cell-cell and cell-ECM, can influence whether a c.pdf
Cell adhesion, both cell-cell and cell-ECM, can influence whether a c.pdf
ahntagencies
 
A(n) is a method of interacting with a PC by manipulating visual ele.pdf
A(n)  is a method of interacting with a PC by manipulating visual ele.pdfA(n)  is a method of interacting with a PC by manipulating visual ele.pdf
A(n) is a method of interacting with a PC by manipulating visual ele.pdf
ahntagencies
 
When Gregor Mendel was developing his ideas of inheritance of cha.pdf
When Gregor Mendel was developing his ideas of inheritance of cha.pdfWhen Gregor Mendel was developing his ideas of inheritance of cha.pdf
When Gregor Mendel was developing his ideas of inheritance of cha.pdf
ahntagencies
 

More from ahntagencies (20)

Mitosis promoting factor is associated with cyclin b. Which class of .pdf
Mitosis promoting factor is associated with cyclin b. Which class of .pdfMitosis promoting factor is associated with cyclin b. Which class of .pdf
Mitosis promoting factor is associated with cyclin b. Which class of .pdf
 
LTE uses an all IP data network, with voice calls reduced to a multim.pdf
LTE uses an all IP data network, with voice calls reduced to a multim.pdfLTE uses an all IP data network, with voice calls reduced to a multim.pdf
LTE uses an all IP data network, with voice calls reduced to a multim.pdf
 
I Need Serious Help with this assignment. Plenty Points to be earned.pdf
I Need Serious Help with this assignment. Plenty Points to be earned.pdfI Need Serious Help with this assignment. Plenty Points to be earned.pdf
I Need Serious Help with this assignment. Plenty Points to be earned.pdf
 
Genes A and B are on different chromosomes. A dihybrid with the geno.pdf
Genes A and B are on different chromosomes. A dihybrid with the geno.pdfGenes A and B are on different chromosomes. A dihybrid with the geno.pdf
Genes A and B are on different chromosomes. A dihybrid with the geno.pdf
 
Do the following program in C++- Create a item class... with and i.pdf
Do the following program in C++- Create a item class... with and i.pdfDo the following program in C++- Create a item class... with and i.pdf
Do the following program in C++- Create a item class... with and i.pdf
 
Explain the process of RNAi and how it contributes to differential .pdf
Explain the process of RNAi and how it contributes to differential .pdfExplain the process of RNAi and how it contributes to differential .pdf
Explain the process of RNAi and how it contributes to differential .pdf
 
Consider the following scenario A population of moderately pigmented.pdf
Consider the following scenario A population of moderately pigmented.pdfConsider the following scenario A population of moderately pigmented.pdf
Consider the following scenario A population of moderately pigmented.pdf
 
Consider the simple analog signal defined by x(t) = sin(2700t) shown.pdf
Consider the simple analog signal defined by x(t) = sin(2700t) shown.pdfConsider the simple analog signal defined by x(t) = sin(2700t) shown.pdf
Consider the simple analog signal defined by x(t) = sin(2700t) shown.pdf
 
Cell adhesion, both cell-cell and cell-ECM, can influence whether a c.pdf
Cell adhesion, both cell-cell and cell-ECM, can influence whether a c.pdfCell adhesion, both cell-cell and cell-ECM, can influence whether a c.pdf
Cell adhesion, both cell-cell and cell-ECM, can influence whether a c.pdf
 
A(n) is a method of interacting with a PC by manipulating visual ele.pdf
A(n)  is a method of interacting with a PC by manipulating visual ele.pdfA(n)  is a method of interacting with a PC by manipulating visual ele.pdf
A(n) is a method of interacting with a PC by manipulating visual ele.pdf
 
You are about to perform a clean install of Windows 7 on a brandnew .pdf
You are about to perform a clean install of Windows 7 on a brandnew .pdfYou are about to perform a clean install of Windows 7 on a brandnew .pdf
You are about to perform a clean install of Windows 7 on a brandnew .pdf
 
Write the equation of a 4th degree polynomial function with the follo.pdf
Write the equation of a 4th degree polynomial function with the follo.pdfWrite the equation of a 4th degree polynomial function with the follo.pdf
Write the equation of a 4th degree polynomial function with the follo.pdf
 
Write a program which repeatedly calls a function named replaceIt() a.pdf
Write a program which repeatedly calls a function named replaceIt() a.pdfWrite a program which repeatedly calls a function named replaceIt() a.pdf
Write a program which repeatedly calls a function named replaceIt() a.pdf
 
Which, of the below choices of inference rules, is used to show that.pdf
Which, of the below choices of inference rules, is used to show that.pdfWhich, of the below choices of inference rules, is used to show that.pdf
Which, of the below choices of inference rules, is used to show that.pdf
 
Which of the following protocols is used for router multicastingA.pdf
Which of the following protocols is used for router multicastingA.pdfWhich of the following protocols is used for router multicastingA.pdf
Which of the following protocols is used for router multicastingA.pdf
 
Which of the following isare not produced by homosporous plants [se.pdf
Which of the following isare not produced by homosporous plants [se.pdfWhich of the following isare not produced by homosporous plants [se.pdf
Which of the following isare not produced by homosporous plants [se.pdf
 
When Gregor Mendel was developing his ideas of inheritance of cha.pdf
When Gregor Mendel was developing his ideas of inheritance of cha.pdfWhen Gregor Mendel was developing his ideas of inheritance of cha.pdf
When Gregor Mendel was developing his ideas of inheritance of cha.pdf
 
what kind of short tandem repeats DNA markers can be used for tracin.pdf
what kind of short tandem repeats DNA markers can be used for tracin.pdfwhat kind of short tandem repeats DNA markers can be used for tracin.pdf
what kind of short tandem repeats DNA markers can be used for tracin.pdf
 
What is the job of a layout managerTo render user interface compo.pdf
What is the job of a layout managerTo render user interface compo.pdfWhat is the job of a layout managerTo render user interface compo.pdf
What is the job of a layout managerTo render user interface compo.pdf
 
Using the Bernoulli method, solve the differential equation t^2 dyd.pdf
Using the Bernoulli method, solve the differential equation t^2 dyd.pdfUsing the Bernoulli method, solve the differential equation t^2 dyd.pdf
Using the Bernoulli method, solve the differential equation t^2 dyd.pdf
 

Recently uploaded

Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 

Recently uploaded (20)

BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptx
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
Scopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS PublicationsScopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS Publications
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
Climbers and Creepers used in landscaping
Climbers and Creepers used in landscapingClimbers and Creepers used in landscaping
Climbers and Creepers used in landscaping
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 

I have code that reads and writes sstrings to file but I am having t.pdf

  • 1. I have code that reads and writes sstrings to file but I am having trouble meeting these requirements. My program writes the string names into the file and not the number of bags. I think a for loop is needed to keep track of how many times their name is written and then check their on board status but I'm not sure. This is the code I have #include #include #include using namespace std; int openOutputFile(); int openInputFile(); void readInputRecord(ifstream& inpt); void writeOutputRecord(ofstream& opt); int count_b = 0; int count_p = 0; string PassengerArray[100]; string BaggageArray[300]; int main() { openInputFile(); openOutputFile(); system("pause"); } void readInputRecord(ifstream& inpt) { string line; int i = 0; //read passanger from file while (getline(inpt, line)) { PassengerArray[i] = line; i++; } cout << "Passanger Array " << endl; for (int k = 0; k
  • 2. Solution while (getline(inpt, line) && line != "") { BaggageArray[i] = line; i++; } count_b = i; cout << "Baggage Array" << endl; for (int k = 0; k