I'm currently having a problem with the void function getdata in my program I'm writing. I'm not quite sure what I'm doing wrong and I could use some help. I'm a novice at this so I'll try my best to follow any instructions.
Here's my code...
Rookie mistake haha. Well I just fixed those and I'm still getting errors for the getdata function. I feel like I'm implementing it wrong when I call it to int main, but I'm unsure where my problem lies for certain.
#include <iostream>
#include <cmath>
#include <string>
#include <iomanip>
#include <fstream>
#include <cstring>
usingnamespace std;
struct birdlist
{
string species;
int birdCount;
};
void getdata (ifstream infile, birdlist [], int& listSize);
void printArray (birdlist list [], int listSize);
void selectionSort( birdlist list[], int listSize);
constint MAX = 200;
string city;
string species;
int birdcount;
int main()
{
string filename;
ifstream infile;
birdlist list [MAX];
int number;
cout << "Input the name of the file you wish to open... (followed by txt.)" << endl;
cin >> filename;
infile.open (filename.c_str());
infile >> species;
cout << species;
getdata (infile, birdlist, listSize);
}
void getdata (ifstream infile, birdlist [], int& listSize)
{
string filename;
string species;
int birdCount;
listSize = 200;
infile >> species;
infile >> birdcount;
getline(infile,city);
cout << city << endl;
cout << endl;
while(infile)
{
infile >> species;
infile >> birdcount;
cout << species << setw(5) << right << birdcount << endl <<endl;
}
infile.close ();
}
errors:
1 2 3 4 5
||In function 'int main()':|
|43|error: expected primary-expression before ',' token|
|43|error: 'listSize' was not declared in this scope|
||=== Build finished: 2 errors, 0 warnings (0 minutes, 0 seconds) ===|