Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8577727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:13:29+00:00 2026-06-11T20:13:29+00:00

I find myself oddly perplexed on this homework assignment. The idea is to create

  • 0

I find myself oddly perplexed on this homework assignment. The idea is to create a Palindrome program, using a specific header the professor wants us to use, but for some reason, when I run it, right after I enter the phrase the program crashes on me.

Here is the program

#include   <iostream>
#include   <ctime>
#include   "STACK.h"
using namespace std;

int main(void)
{
// Declare variables
time_t          a;
STACK<char, 80>     s;
STACK<char, 80>     LR;
STACK<char, 80>     RL;
char            c;
char            c1;
char            c2;

// Displays the current time and date
time(&a);
cout << "Today is " << ctime(&a) << endl;

// Prompts the user to enter the string
cout << "Enter a phrase: ";
while(cin.get(c) && (c != '\n'))
{

    if(isalpha(c)) 
    {
        c = toupper(c); 
        LR.PushStack(c);
        s.PushStack(c);
    }

}

// Copies s into RL in reverse order
while(!(s.EmptyStack() ) )
{
    c = s.PopStack();
    RL.PushStack(c);
}

// Checks for Palindrome
while(!(LR.EmptyStack() ) )
{
    c1 = LR.PopStack();
    c2 = RL.PopStack();

    if( c1 != c2) 
    {
    break;
    }
}


// Displays the result
if(LR.EmptyStack() )
{
    cout << "Palindrome";
}
else
{
    cout << "Not a Palindrome";
}

return 0;
}

And here is the header (I am not allowed to change this)

#ifndef STACK_H
#define STACK_H
template <class T, int n>
class STACK
{ private: T a[n];
    int counter;
  public:
     void  MakeStack() { counter = 0; }
 bool  FullStack()
    { return (counter == n) ? true : false ; }
 bool EmptyStack()
     { return (counter == 0) ? true : false ; }
 void  PushStack(T x)
     { a[counter] = x; counter++; }
 T PopStack()
     { counter--; return a[counter]; }
};
    #endif
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:13:30+00:00Added an answer on June 11, 2026 at 8:13 pm

    You are not calling MakeStack, which will set STACK initial size (0).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I find myself using this method a ton to perform actions based on a
I find myself using this logic a lot: if (isset($array[$key])) $array[$key] += $num; else
I find myself using Resharper's convert to auto property refactoring a lot to remove
I find myself doing this repeatedy. $jq(button).filter(function(){ return this.id.match(/^user_(\d+)_edit$/); }).click(function(){ var matches = this.id.match(/^user_(\d+)_edit$/);
I find myself lacking knowledge around the below. Take this class: public class MyClass
I find myself adding debugging print statements quite often -- stuff like this: print(a_variable_name:
I find myself writing code like this when I want to repeat some execution
I find myself checking to see if javascript elements exist a lot using: if
I find myself breaking this pattern all the time. YAGNI - You Ain't Gonna
I find myself in conflict, regarding which code style I should follow when using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.