ok i have narrowed the fault down to two lines 544 and 545, but i cant see anything that is wrong with it here is the code
any help would be awesome!!!
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(element);
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);
Llist();
~Llist();
};
void Llist::addvigesimalnum(){
//adds to the current vigesimalnum linked list
char usernum;
char cnumber;
char cnum1;
char cnum2;
int remainder;
int num1;
int num2;
element number;
Llist helper;
Llist combo;
listnode * temp1;
listnode * temp2;
temp1 = head;
temp2 = helper.head;
helper.head = NULL;
combo.head = NULL;
remainder = 0;
num1 = 0;
num2 = 0;
cout << "What is the vigesimal number you would like to add?" << endl;
cout << "Enter " << sentinel << " when you are done inputting your number." << endl;
helper.ReadBackward(); //should make the numbers entered go to helper and not change the native object
cout << "here one" << endl;
while (temp1 != NULL){ //temp1 and temp2 are the temp listnodes that
cout << "here 2" << endl;
cnum1 = (temp1 -> data); // Line 544
cnum2 = (temp2 -> data); // Line 545
cout << "here three" << endl;
num1 = digitconvertor(cnum1);
num2 = digitconvertor(cnum2);
remainder = (num1) % (num2);
cout << num1 << " " << num2 << " " << remainder << endl;
if (remainder == 0){
number = (num1) + (num2);
cnumber = convertback(number);
combo.inserttail(cnumber);
temp1 = temp1 -> next;
temp2 = temp2 -> next;
}
else {
number = (num1) + (num2) + remainder;
cnumber = convertback(number);
combo.inserttail(cnumber);
temp1 = temp1 -> next;
temp2 = temp2 -> next;
}
}
while (temp1 != NULL){
combo.inserttail(temp1 -> data);
temp1 = temp1 -> next;
}
//phase 3 harvest remaining from second list
while(temp2 != NULL){
combo.inserttail(temp2 -> data);
temp2 = temp2 -> next;
}
duplicate(combo); // should change the native object to what the combo is
Printinreverse();
Mainmenu();
}
Comment