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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:35:27+00:00 2026-06-10T22:35:27+00:00

Why this stackover flow is happening where as I am using fflush and free

  • 0

Why this stackover flow is happening where as I am using fflush and free in my code.
Please help me.

using namespace std;

    struct abc{
        int x;int y;
        }abc;

int _tmain(int argc, _TCHAR* argv[])
{
    struct abc *xyz = (struct abc *) malloc(sizeof(struct abc));
    xyz->x = 5;
    printf("%d\n", xyz->x);
    //system("pause");
        free(xyz);
     // xyz = NULL;
        fflush(stdout);
        _tmain(NULL, NULL);

    return 0;
}

Edited Code:

xyz:
    struct abc *xyz = (struct abc *) malloc(sizeof(struct abc));
    xyz->x = 5;
    printf("%d\n", xyz->x);
    //system("pause");

    free(xyz);
    xyz = NULL;
    fflush(stdout);
    goto xyz;
  • 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-10T22:35:29+00:00Added an answer on June 10, 2026 at 10:35 pm

    You are unconditonally calling the _tmain() function from your _tmain() function, causing infinite recursion. Every call needs to allocate space on the stack (which is never freed), causing your StackOverflow exception. Take a look at e.g. Wikipedia too fully understand the problem.

    Apart from that, calling the main() function from your own code is ususally not a good idea, as its forbidden by the standard.

    §3.6.1.3: The function main shall not be used within a program.

    Why would you need to do that?

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

Sidebar

Related Questions

i have seen this block of code in this Stackoverflow as a answer of
I'm looking at some code with this form: 1 package com.stackoverflow.java.questions; 2 import java.util.ArrayList;
I am at a loss... not sure exactly why this is happening. I have
I'm using the Zend framework and the openid selector from http://code.google.com/p/openid-selector/ - however I
This is my first post on StackOverflow, so please bear with me. And I
I have the following code sample to illustrate my point. When I load this
Please look at http://www.idea-palette.com I have multiple pages that are being faded in using
We're using Phonegap to develop our mobile app, and we borrowed code from here
This StackOverflow question gave me food for thought on what is a good structure
This StackOverflow answer has an image of KDiff3 highlighting intra-line differences. Does someone know

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.