I've written a C program which runs on a windows PC.
I wrote a text file for debugging purposes which writes when the code gets to certain parts, and if certain parts are true or false.
I completed my code and it works exactly as desired/expected. However when I comment out the code to create and write to file, to try and release the file the program freezes. I've had this before in embedded systems but never on a PC OS before.
Is this a common issue? Are there some causes I should know about?
Below is my code in main.
int main(int argc, char** argv)
{
BOOL running = TRUE;
BOOL get;
//Open debug file
#ifdef DEBUG
FILE* debugFile = openFile("debugFile.txt", "w+");
#endif
//Print start up message to console
printStartUpMessage();
//Initialise variables
initialiseVariables();
while(running)
{
#ifdef DEBUG
fprintf(debugFile, "%s", "1. In start of main loop")
#endif
if(_kbhit())
handleButtonPress();
#ifdef DEBUG
fprintf(debugFile, "%s", "2. Handled buttons");
#endif
do
{
get = getSourceOne();
}while(get);
do
{
#ifdef DEBUG
fprintf(debugFile,"%s","3. Getting source two\n");
#endif
get = getSourceTwo();
#ifdef DEBUG
fprintf(debugFile,"%s %d","4. Got source two...\n", get);
#endif
}while(get);
parseInformation();
#ifdef DEBUG
fprintf(debugFile,"%s","5. Parsed\n");
#endif
running = stillRunning();
}
}