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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:24:01+00:00 2026-05-29T13:24:01+00:00

I have a project that requires different types of iterations. One is function recursion

  • 0

I have a project that requires different types of iterations. One is function recursion on a char array of 5000. After 50 calls it will crash, assuming from stack overflow. Not sure how to get around this.

void functionLoop(int loopInt)
{
#ifdef ___EXSTR_H___
#undef ___EXSTR_H___
#endif
#include "exstr.h"

    ofstream fout;
    fout.open("output.txt");

    int arrayLength =  sizeof ( example_strings ) / 4; // arrayLength = 5000.
    char *stringArray = example_strings[loopInt];
    int charCount = 0;
    while( *stringArray != 0 )
    {
        stringArray++;
        charCount++;
    }
    cout << loopInt + 1 << ": " << charCount << ": " << example_strings[loopInt] << endl;
    loopInt++;
    if(loopInt < arrayLength)
    {   
        functionLoop(loopInt);      
    }
}

EDIT:

I cleaned up the code a lot, got rid of all the variables, moved the header file to a parameter, and gained about 4500 more iterations, but it’s still crashing after 4546. Here’s the updated code:

void functionLoop(char * example_strings[], ofstream &outputFile, int counter)
{     
    outputFile << counter + 1 << ": " << strlen(example_strings[counter]) << ": " << example_strings[counter] << endl;
    counter++;

    if(counter < ARRAY_SIZE)
    {   
        functionLoop(example_strings, outputFile, counter);      
    }
}

Thank you to everyone that helped.

  • 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-29T13:24:02+00:00Added an answer on May 29, 2026 at 1:24 pm

    Pass the array as a parameter to your function, i.e.

    printLoop(outputFile, example_strings, current_index, max_index);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$(.container).hover( function(){ $(.child-1).hide(0); $(.child-2).show(0); },function(){ $(.child-1).show(0); $(.child-2).hide(0); }); A project I have requires that
I have a project that requires the following. Four arrays will be declared in
I have a project that requires some configuration files. I want to keep the
We have an old project that requires occasional maintenance that uses VS2003 and Dot
We have a large MS Access project that requires GUI functionality that is difficult
I have a spec in my current project that requires us to advise the
I have to hand in a software project that requires either a paper or
I have a project I'm working on that requires our WPF application read SMS
I'm doing a project in seam that requires restful URLs. I have a view
In my current project I have a few different interfaces that require me to

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.