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 8710123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:32:35+00:00 2026-06-13T04:32:35+00:00

I am using eclipse for C++ program. After building my code when I am

  • 0

I am using eclipse for C++ program.

After building my code when I am running the code I am getting name.exe has stopped working error.
Same code is working fine here http://codepad.org/2c5xFbLM .

Please help me finding this issue.
Thanks in advance.
My code :

#include<iostream>
#include<math.h>
#include <cstdlib>
using namespace std;

struct node{
    struct node * lc;
    struct node * rc;
    int data;
};

typedef struct node Node;

Node * getNewNode(int data){
    Node * node = NULL;

    node = (Node*)malloc(sizeof(node));
    node -> data = data;
    node -> lc = NULL;
    node -> rc = NULL;

    return node;
}

Node * buildBst(Node * root,int data){
    if(NULL == root){
        return getNewNode(data);
    }
    if(data > root -> data){
        root -> rc = buildBst(root->rc,data);
    }else{
        root -> lc = buildBst(root->lc,data);
    }
    return root;
}

void printInorder(Node * root){
    if(root != NULL){
        printInorder(root -> lc);
        cout << root -> data << " ";
        printInorder(root -> rc);
    }
}

int main(int argc, char* argv[]) {

    int arr [] = {2,3,4,1,5,9,0,3};
    Node * root = NULL;
    for(int i = 0;i < 6; ++i){
        root = buildBst(root,arr[i]);
    }
    printInorder(root);
    cout << endl;
}
  • 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-13T04:32:37+00:00Added an answer on June 13, 2026 at 4:32 am

    Since you’re using C++, use the new operator instead of malloc, the crash happened upon the 14th iteration at your call to malloc, or your 4th node creation, because of the additional padding with debugging, it allowed it in debug mode ( though technically UB otherwise ) and probably wrote through the guard bytes.

    Likewise, it crashed on the malloc code because you were using sizeof(node) vs sizeof(Node).

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

Sidebar

Related Questions

I'm getting a FileNotFoundException when running the following Java 6 code on Eclipse (Indigo)
After writing a long GUI program and getting the right result in the eclipse
I am using Eclipse to program in Java. I tried installing from this site
I'm using Eclipse on Windows to program C++ using Cygwin's toolchain. I would like
I'm trying to program ARM using Eclipse + CDT + yagarto (gnu toolchain) +
Using Eclipse, working with (ANSI) C language, is there any way to view the
When debugging Java code using Eclipse, for collection variables, I saw the modcount member.
I'm working on a large GUI Program and even after years of development I
I am working in Eclipse on Mac. I am using PyDev version 2.6.0.2012062818. I
I have a problem with eclipse debugging. I had a proper working code and

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.