473,785 Members | 2,841 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Divide Error Exception

2 New Member
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 3546
Banfa
9,065 Recognized Expert Moderator Expert
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
5669
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 the error caused by dividing by zero or null values. The specific message i get is: ERROR: floating point exception! The last floating point operation either exceeded legal ranges or was a divide by zero
0
2101
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 data I'm using. SOME of the values in the EXP_NET column are zero, but the sum itself is always non-zero. The query is: TRANSFORM SUM(-)/SUM()*100 AS DATA SELECT TBL.EQUIPMENT AS EQUIPMENT,
5
1307
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. No viruses are found. This has been occurring for a year now... I don't know if it is a specific file, or just the rendering of the files to produce icons for the display in Explorer.exe that is the cause. Anyone have suggestions for me?
8
2107
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 runs fine using 1.1 and on 3 of the 8 machines in our group. It is a Windows application. Our appliation has many user controls, and panels/viewing areas that we show in our app. In our application we several areas where we have to take a...
5
7592
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
3662
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 int) ? Same question for the corresponding unsigned types.
8
4812
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 error. If I attempt to divide a double by zero, the framework returns infinity. From a mathematical standpoint, it would seem to me that the decimal handles this division correctly, while the double's handling of this is flawed. Is there a...
2
5469
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( 0x10, &regs, &regs );
2
2144
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 ; i--) { x = 5 % i; // Divide by zero exception here when i = 0. x++; }
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10330
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10093
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9952
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8976
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7500
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3654
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2880
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.