Random BSODs while running

XeNiM666

I lurk for pizza
Reaction score
138
First, I'm sorry if this is in the wrong section. If so, if GM's can kindly put this in the right section, that would be awesome. :)

Second, here's the problem:
We have this assignment in our school, create a program about Truth Tables and Sets...
I don't need any help with the code though, the problem is that there is a random time that the Blue Screen of Death appears when I try to run the program. When it doesn't show the Blue Screen, it runs my program without problems.
It's been happening at random times, all week exactly, when I'm programming. It's irritating me and I'm afraid that all these random BSODs will harm my computer.
I tried it with 4 different C++ programs, still gives me random BSODs.

I'm using Borland C++ Compiler v5.02. When I compile it, it shows me no errors, only warnings though. Here's the log when I compile:
Code:
Info :Making...
Info :Making...
Info :BACKUP.cpp: build due to .OBJ dependency BACKUP.cpp
Info :  BACKUP.cpp: cached age 11:23:15 PM 3/10/2012  file age 11:43:20 PM 3/10/2012
Info :Compiling C:\USERS\LAGONERA\DESKTOP\DISCREET\BACKUP.cpp
Warn :  BACKUP.cpp(53,12):Conversion may lose significant digits
Warn :  BACKUP.cpp(87,12):Conversion may lose significant digits
Warn :  BACKUP.cpp(228,25):Comparing signed and unsigned values
Warn :  BACKUP.cpp(239,25):Comparing signed and unsigned values
Warn :  BACKUP.cpp(255,2):'x' is declared but never used
Warn :  BACKUP.cpp(205,2):'n' is assigned a value that is never used
Info :Linking C:\USERS\LAGONERA\DESKTOP\DISCREET\BACKUP.exe

If somehow the code has something to do with it, here's the entire code that I'm working on...
It creates a menu for Truth Tables (only, currently), enters an expression, then creates a truth table for the said expression, then returns to the main menu.
Code:
#include <iostream>
#include <conio.h>
#include <windows.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define MAXSET 25
#define MAXMEM 25
#define EXPLEN 50

  // =============================== //
 // FUNCTIONS HANDLING TRUTH TABLES //
// =============================== //
    void TruthMenu();
    void CreateTable();
    void In2Post( char[] );
    void EvaluateTruth( char[] );

    int CountVariables( char[] );
    bool InArray( char[], char, int );

    char Var[ 26 ];
    int VarCount;

    int top = -1;
    char T_STACK[ EXPLEN ];
    char POST[ EXPLEN ];
    char EXP[ EXPLEN ];

    void Push(char);
    char Pop();

  // ======================= //
 // FUNCTIONS HANDLING SETS //
// ======================= //
    void AddSet();
    void AddRelation();

    int Set[ MAXSET ][ MAXMEM ];
    int SetMem[ MAXSET ];
    int CTR;

int main(){
    char c;

    for(;;){
        system( "cls" );
        gotoxy( 39, 8 ); cout << "[1]"; gotoxy( 35, 9 ); cout << "Truth Tables";
        gotoxy( 39, 11 ); cout << "[2]"; gotoxy( 39, 12 ); cout << "Sets";
        gotoxy( 39, 17 ); cout << "[3]"; gotoxy( 35, 18 ); cout << "Exit Program";

        c = getch();
        if ( c == '1' )
            TruthMenu();
        else if ( c == '2' );
        else if ( c == '3' )
            break;
    }

    return 0;
}

    // ==================================================== //
   // ==================================================== //
  //                     TRUTH TABLES                     //
 // ==================================================== //
// ==================================================== //

void TruthMenu(){
    char c;
    int i;
    char msg[25] = "  Press any to continue..";

    for(;;){
        system( "cls" );
        gotoxy( 35, 5 ); cout << "TRUTH TABLES";
        gotoxy( 15, 7 ); cout << "Operators:";
        gotoxy( 18, 8 ); cout << "AND [ & ]";
        gotoxy( 18, 9 ); cout << "NOT [ ~ ]";
        gotoxy( 18, 10 ); cout <<"OR  [ / ]";
        gotoxy( 30, 8 ); cout << "IF  [ > ]";
        gotoxy( 30, 9 ); cout << "IFF [ = ]";
        gotoxy( 15, 12 ); cout << "[C] - Create a Truth Table";
        gotoxy( 15, 13 ); cout << "[R] - Return to Main Menu";

        c = getch();
        if( ( c == 'C' ) || ( c == 'c' ) ){
            gotoxy( 20, 16 ); cout << "Enter your expression:";
            gotoxy( 23, 17 ); cin >> EXP;

            system( "cls" );
            gotoxy( 8, 2 ); cout << "Your Expression is:";
            gotoxy( 10, 3 ); cout << EXP;
            for( i=1; i<25; i++ ){
                gotoxy( 2, i ); cout << msg[ i ] << " |";
            }
            getch();

            In2Post( EXP );
            CreateTable();
            break;
        }
        else if ( ( c == 'R' ) || ( c == 'r' ) )
            break;
    }
}

void In2Post( char exp[] ){
    int i, len = strlen( exp ), p = 0;

    VarCount = 0;
    for( i=0; i<len; i++ ){
        if( exp[ i ] == '(' ){
            Push( exp[ i ] );
        }
        else if( exp[ i ] == ')' ){
            while( T_STACK[ top ] != '(' ){
                POST[ p ] = Pop();
                p++;
            }
            T_STACK[ top ] = NULL;
            top--;
        }
        else if( ( exp[ i ] == '=' ) || ( exp[ i ] == '~' ) || ( exp[ i ] == '&' ) || ( exp[ i ] == '/' ) || ( exp[ i ] == '>' ) ){
            while( ( top != -1 ) && ( T_STACK[ top ] != '(' ) ){
                POST[ p ] = Pop();
                p++;
            }
            Push( exp[ i ] );
        }
        else{
            POST[ p ] = exp[ i ];
            p++;

            if ( VarCount == 0 ){
                Var[ VarCount ] = exp[ i ];
                VarCount++;
            }
            else{
                if ( InArray( Var, exp[ i ], VarCount ) == false ){
                    Var[ VarCount ] = exp[ i ];
                    VarCount++;
                }
            }
        }
    }
    while( top != -1 ){
        if( T_STACK[ top ] == '(' ){
            T_STACK[ top ] = NULL;
            top--;
        }
        else{
            POST[ p ] = Pop();
            p++;
        }
    }
}

void EvaluateTruth( char c[] ){
    bool r, a, b;
    char p;
    int i, len = strlen( c );

    for( i=0; i<len; i++ ){
        if( ( c[ i ] == '=' ) || ( c[ i ] == '&' ) || ( c[ i ] == '/' ) || ( c[ i ] == '>' ) ){
            p = Pop();
            if( p == 't' ) b = true;
            else b = false;

            p = Pop();
            if( p == 't' ) a = true;
            else a = false;

            if( c[ i ] == '&' ) r = ( a && b );
            else if( c[ i ] == '/' ) r = ( a || b );
            else if( c[ i ] == '>' ){
                if( ( a == true ) && ( b == false ) ) r = false;
                else r = true;
            }
            else if( c[ i ] == '=' ){
                if( a == b ) r = true;
                else r = false;
            }

            if( r == true ) Push( 't' );
            else Push( 'f' );
        }
        else if ( c[ i ] == '~' ){
            p = Pop();
            if ( p == 't' ) Push( 'f' );
            else Push( 't' );
        }
        else{
            Push( c[ i ] );
        }
    }

    p = Pop();
    if( p == 't' ) cout << "T";
    else cout << "F";
}

void CreateTable(){
    int n = 0, i, j, k, x;
    char temp[ 26 ];
    char bin[ 26 ];
    char ptemp[ EXPLEN ];

    for( i=0; i<EXPLEN; i++ ) ptemp[ i ] = NULL;
    for( i=0; i<26; i++ ) bin[ i ] = NULL;
    for( i=0; i<VarCount; i++ ){
        bin[ i ] = '0';
        gotoxy( 12 + ( i * 3 ), 5 ); cout << Var[ i ];

        if ( i == ( VarCount - 1 ) ){
            gotoxy( 12 + ( VarCount * 3 ), 5 ); cout << EXP;
        }
    }

    if( VarCount > 0 ){
        n = pow( 2, VarCount );

        for( i=0; i<n; i++ ){
            itoa( i, temp, 2 );

            k = VarCount - strlen( temp );
            for( j=0; j<strlen( temp ); j++ ){
                bin[ k ] = temp[ j ];
                k++;
            }

            for( j=0; j<VarCount; j++ ){
               gotoxy( 12 + ( j * 3 ), 7 + i );
               if( bin[ j ] == '0' ) cout << "T";
               else cout << "F";
            }

            for( j=0; j<strlen( POST ); j++ ){
                ptemp[ j ] = POST[ j ];
                for( k=0; k<VarCount; k++ ){
                    if( ptemp[ j ] == Var[ k ] ){
                        if( bin[ k ] == '0' )
                            ptemp[ j ] = 't';
                        else
                            ptemp[ j ] = 'f';
                    }
                }
            }
            gotoxy( 12 + ( VarCount * 3 ) + ( strlen( EXP ) / 2 ), 7 + i );
            EvaluateTruth( ptemp );
        }
    }
    getch();
}

bool InArray( char ar[], char c, int n ){
    int i;
    for( i=0; i<n; i++ )
         if ( ar[ i ] == c ) return true;
    return false;
}

void Push( char c ){
    if( top == EXPLEN )
        cout << "Stack is full";
    else{
        top++;
        T_STACK[ top ] = c;
    }
}

char Pop(){
    char c = NULL;
    if( top == -1 )
        cout << "Stack is empty";
    else{
        c = T_STACK[ top ];
        T_STACK[ top ] = NULL;
        top--;
    }
    return c;
}





       /*

void AddSet(){
	 int i;
    char c = NULL;

    cout << endl << "Enter Set [" << ( CTR + 1 ) << "]'s members: " << endl;
    for( SetMem[ CTR ] = 0; ( ( c != 'n' ) || ( c == 'N' ) ); SetMem[ CTR ]++ ){
        cout << "  Enter member " << ( SetMem[ CTR ] + 1 ) << ": "; cin >> Set[ CTR ][ SetMem[ CTR ] ];
        cout << "    Enter another member [Y/N]: "; cin >> c;
    }
    SetMem[ CTR ]--;

    cout << endl << "Set [" << ( CTR + 1 ) << "]'s members: { ";
    for( i = 0; i <= SetMem[ CTR ]; i++ ){
        cout << Set[ CTR ][ i ] << " ";
    }
    cout << "}";

    cout << endl << "  Are these values correct [Y/N]: "; cin >> c;
    if ( ( c == 'Y' ) || ( c == 'y' ) ){
        CTR++;
    }
    else if ( ( c == 'N' ) || ( c == 'n' ) ){
        AddSet();
    }
}

void AddRelation(){
    int i;
    char c = NULL;

    cout << endl << "Operators:" << endl << "  / - Intersection" << endl << "  + - Union" << endl;
    cout << "Enter Operator: "; cin >> c;
    if ( c == '+' ){
    }
    else if ( c == '/' ){
    }
    else{
    }
}       */

I tried to search for the problem on the net but no luck... Maybe you guys can help...

Thanks in advanced!

Off-topic: I miss you TH.net, especially WEHZ... <3
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top