Function question Part 2 ( RUN TIME ERROR PROBLEM ) 
Author Message
 Function question Part 2 ( RUN TIME ERROR PROBLEM )

Well,  I've recently recieved a reply to my post and I've
made the necessary changes and still I get the run time
error.  For some reason, before it was my
variable "number1,"  now since the changes it is
the "counter" that creates this run time error.  Here is
my code.  just add comments to clue me in on what's going
on.  

#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int Random_num ( void );

int main()
{

        int counter,
                number1, number2,
                panswer,  
                R_answer;

         srand( time( 0 ) );
         number1 = Random_num();
         number2 = Random_num();
         R_answer = number1 + number1;  

         while ( counter != 4 )
         {

         cout << number1 << " + " << number1 << " = ";
         cin >> panswer;
         counter++;
         if (   panswer != R_answer )
                 cout << " You're a loser ";
         else
                 cout << " Cool!" << endl;
         }
         return 0;

Quote:
}

int Random_num ( void )
{
     int num;
     num = 1 + rand() % 9;

         return num;

Quote:
}



Thu, 15 Dec 2005 13:17:09 GMT  
 Function question Part 2 ( RUN TIME ERROR PROBLEM )

Quote:
>Well,  I've recently recieved a reply to my post and I've
>made the necessary changes and still I get the run time
>error.  For some reason, before it was my
>variable "number1,"  now since the changes it is
>the "counter" that creates this run time error.

You've not initialised "counter" before it's used (tested).

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq



Thu, 15 Dec 2005 21:03:19 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. run time error with GetFieldValue function

2. C Run-Time Error R6025 - pure virtual function called

3. C Run-Time library Problem - Port I/O Functions can not be found

4. Run time Release mode error but no Debug mode error

5. Abnormal Program Termination Error -- MS C++ Run Time Library Error

6. Abnormal Program Termination Error -- MS C++ Run Time Library Error

7. Abnormal Program Termination Error -- MS C++ Run Time Library Error

8. Calling DLL functions without known function name, parameter-list until run-time

9. Timing problem in calling run-time loading DLL

10. Timing problem in run-time loading DLL

11. Run-time Error??!!

12. Specialised tool for run-time error detection

 

 
Powered by phpBB® Forum Software