for some reason in my program when i try and add a number to my current number i get a floating point exception now i have narrowed down were it stops working to line 398 but i dont know as to why it is stopping right there. Here is my code any help would be great.
Code:
#include <iostream>
#include <iomanip>
#include <stdlib.h>
using namespace std;
#undef NULL //un defines anything from a class that has the same name as one of your constants
typedef int element;
const int NULL = 0;
const char sentinel = '#';
class listnode{
public:
element data;
listnode* next;
};
class Llist{
private:
listnode* head;
listnode* tail;
char vignum;
public:
void read();
void print();
void clean();
void ReadBackward();
char read_element();
void Inserthead(element);
void inserttail(char);
element DeleteHead();
void steal(Llist&);
void append(Llist&);
void duplicate(Llist&);
void reverse();
void Mergeordered(Llist&, Llist&);
void Printinreverse();
void Mainmenu();
void Helpmenu();
void addvigesimalnum();
void newvigesimalnum();
void multiplyvigesimalnum();
int digitconvertor(char);
char convertback(int);
void Multiadd(int);
void difadd(Llist & second, Llist & combo, Llist & copy);
Llist();
~Llist();
};
void Llist::difadd(Llist & second, Llist & combo, Llist & copy){
char cnum1;
char cnum2;
char cnumber;
element num1;
element num2;
element number;
element remainder;
listnode * temp1;
listnode * temp2;
temp1 = copy.head;
temp2 = second.head;
combo.head = NULL;
while((temp1 != NULL)&&(temp2 != NULL)){
cnum1 = temp1 -> data;
cnum2 = temp2 -> data;
cnum1 = DeleteHead();
cnum2 = second.DeleteHead();
num1 = digitconvertor(cnum1);
num2 = digitconvertor(cnum2);
number = (num1 % num2) + remainder; // Line 398
remainder = (num1 + num2) / 20;
cnumber = convertback(number);
combo.inserttail(cnumber);
temp1 = temp1 -> next;
temp2 = temp2 -> next;
cout << "here 1" << endl;
combo.print();
}
}
Comment