I got this error in the following program for line 22, and I do not know how to fix it.
thank you very much!Code:// Brett Balzer // Converting to binary // 11/01/06 #include <iostream> using namespace std; struct stack { int count; struct node *top; }; struct node { int data; struct node *next; }; bool pushStack (struct stack *stack, int data) bool popStack (struct stack *stack, int &data) int main() { int number; int digit; struct stack theStack; struct stack *stack; stack = &theStack; cout << "Enter a decimal number" << endl; cin >> number; while (number > 0) { digit = number % 2; number = number/2; pushOK = pushStack (stack, digit); if (pushOK == false) { cout << "Stack overflow creating digit" << endl; return 0; } } while (stack->top != NULL) { popStack (stack, digit); cout << digit; } return 0; } bool pushStack (struct stack *stack, int data) { bool success; struct node *newptr; newptr = new struct node; newptr->data = data; newptr->next = stack->top; stack->top = newptr; stack->count = stack->count + 1; success = true; return success; } bool popStack (struct stack *stack, int &data) { bool success; struct node *dltPtr; if (stack->top == NULL) { success = false; } else { dltPtr = stack->top; data = stack->top->data; stack->top = stack->top->next; stack->count = stack->count - 1; free (dltPtr); success = true; } }



LinkBack URL
About LinkBacks


