Hello there, I just read the file line by line but this line (All interior angles.... ) doesn't print out separately. it

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Hello there, I just read the file line by line but this line (All interior angles.... ) doesn't print out separately. it

Post by answerhappygod »

Hello there, I just read the file line by line but this line
(All interior angles.... ) doesn't print out separately. it is
USING C++.. The output must
print it separately. I hope it is clear to you. you can
compile my code below and edit it inside my code
please.
Here is my code.
int main(){
string filename;
cout << "Enter the main file ";
cin >> filename;
string category , description, d1 ,d2, d3 ,d4,d5;
int test, cate, num1 , num2, i=1, j=1, num3,num4,
num5,num6;

ifstream fname(filename);
fname >> test;
fname >> cate;
fname >> category >> num1 >>
num2;
cout << category << num1 << num2
<< endl;
while(j <= num1)
{
fname >> d1;
cout << d1 << endl;
j++;
}
cout << endl;

fname >> d2 >> num3 >> num4;

cout << d2 << endl;

while(i <= num3){
fname >> d3;
cout << d3 <<
endl;
i++;
}

//this only two lines need to print
out "All interior angles of a convex polygon are less than
90 degrees
// Their sum product and difference is not the remainder ".
// the code below doesn't work to print out that only two
lines ("All interior angles...")
while(getline(fname,description,' ')){
istringstream
iss(description);
while(getline(iss,d4,' ')
cout << d4
<< endl;
}

fname.close();
}
Here is the input file
myfile.txt
1
Geometrical 4 2
point
convex
All interior angles of a convex polygon are less than 90
degrees
Their sum product and difference is not the remainder
2
CompSci 5 2
time
computational
data
scalability
NP-Complete
Physics 1 1
energy
NP-Hard algorithms take a long time to compute
Force equals mass times acceleration
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply