I need help with this hw problem i have been working on for this week. I cant get any in class help since we keep having snowdays and i'm a beginner to c++.
*Read names.txt into array of pointers to SurnameInfo structures.
*Write a binary search function with the prototype
*SurnameInfo * binarySearch(char *)
where the parameter is a c-string that is a surname and the return value is a pointer to the SurnameInfo structure for the surname.
*Write a mostPopular function that lists the top 20 surnames with the highest percentage and with count larger than 10,000 for each of the six races.
***This is what i have so far
***there is an attached file also of a excel file with names and numbers next to them in 5 colums
[Put the code you need help with here.
Put the code you need help with here.
[#include <iostream>
usingnamespace std;
struct SurnameInfo
{
char *name;
int count;
float pctrace[6];
};
int main()
{
{SurnameInfo * surnames[MAXARRAY];
char line[MAXLINE];
ifstream inputfile;
inputfile.open("names.csv");
if (!inputfile) return; // can’t open
inputfile.getline(line, MAXLINE); // skip title
inputfile.getline(line, MAXLINE);
numberOfNames = 0; // global variable
while (!inputfile.eof()) // not end of file
{
processLine(line, numberOfNames++);
inputfile.getline(line, MAXLINE);
}
inputfile.close();
}}
You pasted your code in the wrong spot, it needs to be [code]between the code tags[/code] in order for it to have line numbers and syntax highlighting. You can edit your post to fix it.
Is your class a C class, or a C++ class? It looks like it is mixing C and C++, which will make things really difficult for you.