inputing binary into structure help

okay so i am basically trying to figure out how to read a binary text file. I'm trying to read a file with hockey stats including name, goals, and assists and put the information into a structure. i can compile it, but when i try to build it, i got an error saying, "undefined reference to 'WinMain@16'". I feel like i've tried everything and this is what i think is closest. Any help would be sickkkkk.




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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <iostream>
#include <iomanip>
#include <fstream>

using namespace std;

const int MAX = 25;

struct playerInfo
{
char playerName[MAX];
int goalsScored;
int assist;
};

playerInfo players[MAX];
playerInfo player;

int buildAr()
{

std::ifstream statFile;

statFile.open("binary_hockey.txt", ios::binary);

int sub1=0;



if ( statFile.fail() )     //test to see if the file opened correctly
  {
  cout << "open for binary_hockey.txt failed";
  exit(-1);
  }

	

	statFile.read( (char *) &player, sizeof(playerInfo) );


	while(statFile)		//loading information into appropriate  arrays
	{
	cout<<player.goalsScored;
	sub1+=1;
	statFile.read( (char *) &player, sizeof(playerInfo) );
	}
	

	

	
  statFile.close();		//closing file
  
 
  return sub1;		//returning the number of players
}

You don't have a main function anywhere, you need one to compile/run your code.
Topic archived. No new replies allowed.