Exemplo n.º 1
0
int main(int argc, char* argv[]) {

    int debuggingMode = 0;
    StackPtr stack; //the pointer to the stack for chars
    stack = stk_create(); //create the stack

    if(argv[1] != NULL) {
        if(strcmp(argv[1], "-d\n")) {
            debuggingMode = 1;
        }
    }

    char input[300]; //assuming input will be less than 300 characters
    int comp;

    //Ask the user for input
    printf("Enter symbols you'd like checked for balance or Q to quit: ");
    fgets(input, 300, stdin);

   while(strcmp("Q\n", input) != 0 && strcmp("q\n", input) != 0) {

        checkBalanced(stack, input, debuggingMode);

        stk_clear(stack);

        printf("Enter symbols you'd like checked for balance or Q to quit: ");
        fgets(input, 300, stdin);

    }

    return 0;
}
Exemplo n.º 2
0
static void creg_set( young_heap_t *heap, word k )
{
  word *globals = DATA(heap)->globals;

  stk_clear( globals );
  globals[ G_CONT ] = k;
  if (!stk_restore_frame( globals ))
    stack_overflow( heap );                        /* [sic] */
}