I am trying to save binary information. But this is the first time I am really using it. Compiler just really hates my function... :/
code follows .c source attached
Code:
/*Sean 'Prime'
Exam 4
11/17/2011
This program plays the battleship game. It allows the player to choose where to hide their ships,
the AI hide ships. The game is played and the AI hunts the players ships, through randomly chosen
coordinates.
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <Windows.h>
//================================
void pause ();
void clear ();
void pauseNClear ();
void printLogo ();
int mainMenu ();
void printGameLogo ();
void loadHighScores (SCORE *high);
//================================
typedef struct {
char names[10];
int scores[10];
}SCORE;
//================================
int main (){
int choice;
SCORE high = {0,0};
loadHighScores(&high);
printLogo();
do{
choice = mainMenu();
}while (choice != 3);
pause();
}
void loadHighScores (SCORE *high){
int start = 0;
FILE *the_scores;
the_scores = fopen ("BattleshipHighScores.bin", "rb+");
if (the_scores == NULL){
printf ("This did not work.\n");
pauseNClear();
}
if (fread (&start,sizeof(int),1,the_scores) !=1){ /*check to see if there are high scores on start up*/
rewind(the_scores);
start = 1; /*if not lets put some in*/
fwrite (&start,sizeof(start),1,the_scores);
fwrite (&high, sizeof(sizeof(SCORE)),1,the_scores);
}
rewind(the_scores);
fseek(the_scores,1,0);
fread (&high,sizeof(SCORES),1,the_scores);
}
here is the error report:
Code:
1>------ Build started: Project: battleship, Configuration: Debug Win32 ------
1> exam4.c
1>d:\dropbox\school\c programming\battleship\battleship\exam4.c(22): error C2143: syntax error : missing ')' before '*'
1>d:\dropbox\school\c programming\battleship\battleship\exam4.c(22): error C2143: syntax error : missing '{' before '*'
1>d:\dropbox\school\c programming\battleship\battleship\exam4.c(22): error C2059: syntax error : ')'
1>d:\dropbox\school\c programming\battleship\battleship\exam4.c(34): warning C4013: 'loadHighScores' undefined; assuming extern returning int
1>d:\dropbox\school\c programming\battleship\battleship\exam4.c(94): warning C4013: 'intScan' undefined; assuming extern returning int
1>d:\dropbox\school\c programming\battleship\battleship\exam4.c(116): error C2371: 'loadHighScores' : redefinition; different basic types
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========