I got it to work this way!
// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple project that uses Dark GDK
// it contains the basic code for a GDK application
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
#include <string.h>
//project constants
const int NoScores = 5;
const int MaxStrSize = 10;
const int LineHeight = 20;
const int SaveFile = 1;
//declare default values for names and scores
const char DefaultNames [NoScores][MaxStrSize] = {"Happy", "Dopey", "Sleepy", "Grumpy", "Doc"};
const int DefaultScores [NoScores] = {4,2,3,5,1};
//function prototypes
void DisplayScores (int , int &, int [NoScores], char [NoScores][MaxStrSize]);
void BubbleSort (int , int &, int [NoScores], char [NoScores][MaxStrSize]);
void LoadHighScores (int [NoScores], char [NoScores][MaxStrSize]);
void SaveHighScores (int [NoScores], char [NoScores][MaxStrSize]);
// the main entry point for the application is this function
void DarkGDK ( void )
{
//declare a 2d char array to hold name strings
char names [NoScores][MaxStrSize];
// int array to hold scores
int scores [NoScores];
//text display variables
int ypos = 20, xpos = 20;
char playerName [MaxStrSize];
int PlayerScore = 0;
//Load data from file if it exists or load default values
LoadHighScores(scores, names);
dbText(ypos, xpos, "Unsorted scores");
DisplayScores(xpos, ypos, scores, names);
dbText(xpos, ypos+LineHeight,"Press any key to sort...");
dbWaitKey();
//call function to sort arrays
BubbleSort(xpos, ypos, scores, names);
//display sorted array
ypos+=40;
dbText (xpos, ypos, "Sorted scores");
DisplayScores(xpos, ypos, scores, names);
dbText(xpos, ypos, "Press any key to continue...");
dbWaitKey();
//get username and score
dbCLS();
dbPrint("Enter name");
//error checking to be added for names longer than char string size
strcpy(playerName, dbInput());
dbPrint("Enter your score");
PlayerScore=atoi(dbInput());
//check if player score is bigger than the last entry in array
if(PlayerScore>scores[NoScores-1])
{
scores[NoScores-1] = PlayerScore;
strcpy(names [NoScores-1], playerName);
//resort array
BubbleSort(xpos, ypos, scores, names);
}//end if
//display sorted arrays
dbCLS();
ypos=40;
dbText(xpos, ypos, "sorted scores");
DisplayScores(xpos, ypos, scores, names);
dbText(xpos, ypos, "Press any key to continue...");
dbWaitKey();
SaveHighScores(scores, names);
//return back to windows
return;
}
void DisplayScores(int xpos, int &ypos, int scores[NoScores], char names[NoScores][MaxStrSize])
{
//display arrays to screen
for (int index=0;index<NoScores;index++)
{
ypos+=LineHeight;
dbText(xpos, ypos, names[index]);
dbText(xpos+60, ypos, dbStr(scores[index]));
}
ypos+=LineHeight;
}//end function DisplayScores
void BubbleSort(int xpos, int &ypos, int scores[NoScores], char names[NoScores][MaxStrSize])
{
//declare temp variables to store data being swapped
int tempNum;
char tempStr[MaxStrSize];
//flag, set to true to start the first pass
bool swapped=true;
//cycle through array till no more swaps
while (swapped==true)
{
swapped = false;
for (int i=0;i<(NoScores-1);i++)
{
if(scores[i+1]>scores[i])
{
//swap scores in number array
tempNum=scores[i];
scores[i]=scores[i+1];
scores[i+1]=tempNum;
swapped=true;
//swap strings in char array
strcpy(tempStr,names[i]);
strcpy(names[i],names[i+1]);
strcpy(names[i+1],tempStr);
}//end if
}//end for loop
}//end while
}//end function BubbleSort
void LoadHighScores(int scores[NoScores], char names[NoScores][MaxStrSize])
{
if(dbFileExist("GameSave.txt"))
{
//read from file to populate arrays then delete file
dbOpenToRead(SaveFile, "GameSave.txt");
for(int index=0; index<NoScores; index++)
{
strcpy(names[index], dbReadString(SaveFile));
scores[index]=dbReadFile(SaveFile);
}//end for loop
dbCloseFile(SaveFile);
dbDeleteFile("GameSave.txt");
}//end if
else
{
//load arrays with default values
for(int count=0; count<NoScores; count++)
{
strcpy(names[count], DefaultNames[count]);
scores[count]=DefaultScores[count];
}//end for loop
}//end else
}//end function LoadHighScores
void SaveHighScores(int scores[NoScores], char names[NoScores][MaxStrSize])
{
dbOpenToWrite(SaveFile,"GameSave.txt");
for (int count=0; count<NoScores; count++)
{
dbWriteString(SaveFile,names[count]);
dbWriteFile(SaveFile,scores[count]);
}//end for loop
dbCloseFile(SaveFile);
}//end function SaveHighScores