2021年4月10日星期六

How to create a filereading program that loads a file of codes

Basically my program is giving me a load of errors with my filereading program when trying to compile. The goal is to get the user to enter the threshold number and the strings that are equal to or greater than that threshold number will be outputted. The program fails at that because there are several errors with the code. How to fix the errors within the code?

   #include <iostream>     #include <fstream>     #include <cstdlib>     using namespace std;         int read_airports(string cities[], int threshold);         int main()    {        ifstream fin;           fin.open("airports.txt");           if (fin.is_open())        {            string cities[20];            int count, threshold;               count = read_airports(cities, threshold);            while(!fin.eof())            {            fin >> threshold;            cout << "Enter a threshold number" << endl;            cin >> threshold;               if (fin.good())            {                if (cities >= threshold)                {                    cout << cities << endl;                }            }              }            fin.close();        }           return 0;    }          int read_airports(string cities[], int threshold)    {    }  

Here is the text file where this code is based off of. LAX Los-Angeles 40 JFK New-York 39 IAH Houston 26 LCY London 34 PAR Paris 15 TYO Tokyo 11 SEL Seoul 5 YYZ Toronto 28

https://stackoverflow.com/questions/67040804/how-to-create-a-filereading-program-that-loads-a-file-of-codes April 11, 2021 at 09:57AM

没有评论:

发表评论