Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#defines NB_MEM 10
int scores[NB_MEM+1]; // one more than number of already existing scores
int moves_x;
int moves_o;
bool wonx;
bool wono;
QFile file;
file.setFileName("highscores.txt");
file.open( QIODevice::ReadOnly );
QDataStream in( &file );
for( int count = 0; (count < NB_MEM) || (! file.atEnd()); count++ ) in >> scores[count];
file.close();
if ( wonx ) scores[NB_MEM] = moves_x;
else if( wono ) scores[NB_MEM] = moves_o;
int_qsort( scores, NB_MEM+1 );
file.open( QIODevice::WriteOnly );
QDataStream out( &file );
for( int count = 0; count < NB_MEM; count++ ) out << scores[count];
file.close();
|
This post has been edited 2 times, last edit by "Nicolas SOUCHON" (May 6th 2008, 8:47am)