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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:44:57+00:00 2026-05-26T12:44:57+00:00

This is an extended question from How can i remove this Segmentation fault in

  • 0

This is an extended question from

How can i remove this Segmentation fault in C Program

here segmentation fault occur because of stack overflow due to recursion so manny times

so i have changed his code like this..

make a MACRO insted of that function so function call is removed

#include <stdio.h>

static inline void p(char *a, int b); 


#define MAGIC(a,b)  p(a,b) 

void p(char *a, int b) 
{
    static long int i = 0;

    if (i != 350000) 
    {
        printf("\n%ld \t at Hi hello", i);
        i++;
        return MAGIC(a, b);
    } else 
    {
        return;
    }
}


int main() 
{
    char *a = "HI";
    int b = 10;
    MAGIC(a, b);
    printf("\nComplete");
    return 0;

}

still i am getting segmentation fault …still stack overflow…. why?

  • 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-05-26T12:44:58+00:00Added an answer on May 26, 2026 at 12:44 pm

    Change return MAGIC(a, b); to

    goto START; and add a START label in the beginning of the function.

    Edit:

    Example using a while loop:

    void p(char *a, int b) 
    {
        static long int i = 0;
    
        while (i != 350000) 
        {
            printf("\n%ld \t at Hi hello", i);
            i++;
        } 
    }
    

    Example using a for loop:

    void p(char *a, int b) 
    {
        long int i = 0; // static seems wrong here
    
        for (;i != 350000; i++) 
        {
            printf("\n%ld \t at Hi hello", i);
        } 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the first time i'm asking a question here at stack overflow so
This is question about MVC web-app architecture, and how it can be extended to
This question is similar to How can I specifiy what access I need from
I recently extended with UserProfile so my admin.py looks like this: from django.contrib import
I'm trying to retrieve a variable from an extended class. This is how my
This question was asked already here , but rather than answering the specific question,
So this is more of a question due to not knowing the right word,
This is a follow up of another question here on SO . I have
I can't find an answer to this question anywhere. How can I convert a
As per this MSDN article: W3C Extended Log File Format (IIS 6.0) It says

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.