This program keeps crashing before it is over .
If only get to the word eutc then it crashes !
How do i prevent it from crashing ?



Code:
#include <iostream.h>
#include <fstream.h>

void refill() ;
void fill ( ) ;
void testif ( ) ;
void addchar ( ) ;
void filla ( ) ;

int i = 0 ;
int hold ;
char array[50]  ;
int num ; 
int    line ;
const int maxchar = 7 ;
ofstream File;

int main ()
{
    File.open("File.txt",ios::out);
    line = 0 ;
    num = 0 ;
    array[1] = '\0' ;
    fill ( ) ;
    File.close();

    return 0 ;

}

void fill (  ) 
{
    if ( line < maxchar )
    {

    array[num] = 'a' ;
    array[num +1] = '\0' ;
    for ( i = 0 ; i < 25 ; i++ )
    {
        File << array << " " ;
        array[num]++ ;    
    }
        File << array << " " ;
    testif ( ) ;
    }
}

void testif ( ) 
{
    if ( line < maxchar ) {    
    if ( line == 0)
        addchar( ) ;
    if ( array [line -1 ] == 'z' ){
        line-- ;
        testif ( ) ;
    }
    else {
        array [line - 1 ] ++ ;
        hold = line ;
        refill () ;
        filla() ;
    }
        testif ( ) ;
    }
}

void addchar () 
{
    if ( line < maxchar ) 
    {
        num ++ ;
        line = num ;
        array [num +1] = '\0' ;
        for ( i = 0 ; i < num ; i++ )
            array[i] = 'a' ;
        filla( ) ;
    }

}

void filla ( ) 
{
    if ( line < maxchar )
    {
    array[num] = 'a' ;
    array[num +1] = '\0' ;
    for ( i = 0 ; i < 25 ; i++ )
    {
        File << array << " " ;
        array[num]++ ;    
    }
        File << array << " " ;
    testif ( ) ;
    }
}

void refill()
{
    if ( line < maxchar )
    {

        for ( hold ; hold <= num ; hold++ ) {
            array[hold] = 'a' ; 
            }
        line  = num ;
        filla() ;
    }
}

Last edited by shabbir; 26Apr2009 at 09:04.. Reason: Code blocks