hw help

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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Put the code you need help with here.
[#include <iostream>
using namespace 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();
}}
Last edited on
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.
Topic archived. No new replies allowed.