473,320 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Divide Error Exception

hi
I got this error: "Divide-error Exception 0x3D27:0x14D3 Resumable Processor Fault" in Turbo C++ 4.5(Win 16) in a program that uses multi-level Inheritance.
The problem occurs when I try to create an object of the last derived class(found out using trace).All the derived classes are derived using public visibility mode.
Code snippet:

Expand|Select|Wrap|Line Numbers
  1. class Finale:public R_mov
  2. {  int PC2[8][6],Key_t[56],t_cnt;
  3.     protected:
  4.     int Key_final[16][48];
  5.     public:
  6.     Finale();
  7.     void Lk_up_pc2();
  8.     void display();
  9.     ~Finale(){}
  10. };
  11. Finale::Finale()
  12. {  int in;
  13.     ifstream fin;
  14.     fin.open("PC2.DAT");
  15.     for(int i=1;i<=8;i++)
  16.     {  for(int j=1;j<=6;j++)
  17.         {  fin>>in;
  18.             PC2[i][j]=in;
  19.         }
  20.     }
  21.     fin.close();
  22. }
  23. void Finale::Lk_up_pc2()
  24. { for(int i=1;i<=16;i++)
  25.   {  for(int j=1;j<3;j++)
  26.       {  t_cnt=1;
  27.           for(int k=1;k<=28;k++)
  28.           {  if(j==1)
  29.                  Key_t[t_cnt]=cn[i][k];
  30.               else
  31.                  Key_t[t_cnt]=dn[i][k];
  32.               t_cnt++;
  33.           }
  34.       }
  35.       t_cnt=1;
  36.       for(j=1;j<=8;j++)
  37.       {  for(int k=1;k<=6;k++)
  38.           {  Key_final[i][t_cnt]=Key_t[PC2[j][k]];
  39.               t_cnt++;
  40.           }
  41.       }
  42.   }
  43. }
  44. void Finale::display()
  45. {  for(int i=1;i<=16;i++)
  46.     {  cout<<"\n\nKey["<<i<<"]:";
  47.         for(int j=1;j<=48;j++)
  48.             cout<<Key_final[i][j];
  49.         cout<<endl;
  50.         getch();
  51.     }
  52.     getch();
  53. }
  54.  
The error occurs in main() at the line where I declare an object of type Finale.
Any suggestions?
Feb 2 '07 #1
1 3513
Banfa
9,065 Expert Mod 8TB
You have your array indexes wrong

You declare the array

int PC2[8][6];

that means that valid values for the first index are in the range 0 - 7 inclusive and valid values for the second index are in the range 0 - 5 inclusive. C programmers start counting at 0.

In the constructor you have

for(int i=1;i<=8;i++)
{
    for(int j=1;j<=6;j++)
    {
        fin>>in;
        PC2[i][j]=in;
    }
}

Your loops run in the range 1 - 8 and 1 - 6, this falls outside the valid range for the array indexes and accessing these invalid indexes is likely to cause some sort of memory corruption.
Feb 2 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mike Leahy | last post by:
All... I have a query that calculates various using variables from a survey database. As with any survey, there are many instantces of null values. I'm wondering if there is any way to escape...
0
by: Gary Carson | last post by:
Can anyone tell why the query below would throw a divide-by-zero error? The only reason I can see for the error happening would be if SUM() came out to be zero, but this never happens with the...
5
by: John | last post by:
I get a 'divide by zero' exception when I scroll in a subdirectory of 'My Pictures'. This subdirectory is full of .ico, .bmp, .png files that I use for button images in my Windows Forms projects. ...
8
by: WhiteWizard | last post by:
Have we got a STRANGE one going here. We converted from 1.1 to 2.0 about 2 weeks ago and this has been a problem since then...but only on SOME machines in our development group. The application...
5
by: Neo | last post by:
Hi Friends, I am trying following code int main(void) { try { int i,j,k; i=10; j=0;
40
by: Spiros Bousbouras | last post by:
Do you have an example of an implementation where sizeof(short int) does not divide sizeof(int) or sizeof(int) does not divide sizeof(long int) or sizeof(long int) does not divide sizeof(long long...
8
by: =?Utf-8?B?bWljaGFlbGd3ZWllcg==?= | last post by:
Hello! I was working on some code the other day, and I came across an odd discrepancy between the decimal and the double type. If I attempt to divide a decimal by zero, the framework throws an...
2
by: gygulance | last post by:
Hi! I have encountered "Divide error" exception while running the following program in TurboC: #include <dos.h> union REGS regs; main() { regs.h.ah = 0; regs.h.al = 1; int86(...
2
by: aniait | last post by:
Hi, I just came across a faulty code of mine when working on Symbian C++ code. It threw an exception for the code fragment below (or something similar to this): int x; for(int i = 2; i >= 0 ;...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.