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

  • SEARCH
  • Home
  • 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 8965843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:53:53+00:00 2026-06-15T16:53:53+00:00

I was trying to implement a solution for palindrome, I think my logic is

  • 0

I was trying to implement a solution for palindrome, I think my logic is correct, but my program gets stuck in an infinite loop and I get an error message of “Prep.exe has stopped working”

int main()
{
    string word, reverse;

    cout << "Please enter a word to test for palindrome : ";
    cin >> word;
    cout << "Your word is: "<< word << endl;

    int i = 0;
    int size = word.length() - 1;
    while (size >= 0)
    {
        reverse[i++] = word[size--];
        //cout << reverse[i++];
    }

    cout << "The reversed word is: " << reverse << endl;


    if (word == reverse)
        cout << "It is palindrome" << endl;
    else
        cout << "It is not a palindrome" << endl;
}

I’m not sure what I am doing wrong with my while loop. I keep on decrementing it and and I have a valid exit condition, so why does it get stuck in a loop?

  • 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-15T16:53:54+00:00Added an answer on June 15, 2026 at 4:53 pm

    You’re not getting an infinite loop; you’re getting a crash due to an Out Of Bounds access in the line reverse[i++] because reverse is an empty string. Try using the reverse.push_back() function instead.

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

Sidebar

Related Questions

I trying to implement fileUpload , But I get an error described below. i
I'm trying to implement this accepted solution for displaying a custom error message: https://stackoverflow.com/a/5229581/141172
Where is TextTransform.exe located? I'm trying to implement the solution in this post: Get
I'm currently trying to implement a destroy/remove method for views but I can't get
I'm trying to implement a jQuery function with an infinite loop to animate the
I'm trying to implement the solution found here , but once I replace my
I have been trying to implement the solution referenced at: Error when trying to
I'm trying to implement this solution to get around the blank page in Android's
I'm trying to implement a solution using .htaccess and wildcard subdomains so that http://subdomain.example.com
Just trying to implement a simple audit logging solution with Grails 2.0.2 and it

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.