N Base Function, Out of Memory?

I have looked over all the commands in the C language and tried many ways to structure this program, but I am having one heck of a time getting it to stop running out of memory.

What the program does: Asks you for n inputs. Then, for each input, you designate a character set. The program figures out every possible combination.

For example: on the first prompt, input a "3" for a string three characters long, then "press return". Then, for each character set, input a "1" and a "0" and press return. After the third character set is entered, the program will immediately start. It will give you unique instances for each possible outcome.

Now for my error, try putting in "12" for elements. It won't allow me to input my character sets.

What is going on? How do I make this program do large outcomes?

Here is my program, it's pretty short. I tried to write it tight as possible, so hopefully you find it clean and easy to understand, because I have no comments. ( If you really, really want comments, I will write them, but only if you need them.)

#include

FILE *f;

struct s_base
{
int alphachar;
int omegachar;
int character;
} ex[25];

int carry = 0;

int unique = 0;
int v = 0;
int gp;
int e;

int emax = 1;

int g = 1;

void Print()
{
int i;

char c;

for( i = (e-1); i > -1; i-- )
{
fseek( f, ex[i].character, 0L );
fread( &c, 1, 1, f );
printf("%c", c );
}
g++;
printf(" ");
printf("%i ", g );
unique++;
return;
}

void Function()
{
char c;

if( ex[v].character == ex[v].omegachar )
{
ex[v].character = ex[v].alphachar;
v++;
carry += 1;
if( carry > 1 )
{
ex[v-1].character++;
carry = 1;
}
Function();
}

ex[v].character++;

fseek( f, ex[v].character, 0L );
fread( &c, 1, 1, f );

fseek( f, gp, 0L );
fwrite( &c, 1, 1, f );

gp++;

v = 0;

if( unique < emax )
{
if( !carry )
Print();
carry = 0;
Function();
}

return;
}

void Init()
{
int i;
int count = 0;

char s[100];

char c;

printf( "
Enter Elements: " );
scanf( "%i", &e );

for( i = 0; i < e; i++ )
{
printf( "
Enter Character Set %i: ", i );
scanf( "%s", s );

fwrite( &s, strlen(s), 1, f );
count += strlen(s);

ex[i].alphachar = ( count - strlen(s) ) - 1;
ex[i].omegachar = count - 1;
ex[i].character = count - strlen(s);

emax *= strlen(s);
}

gp = count;

for( i = (e-1); i > -1; i-- )
{
fseek( f, ex[i].alphachar + 1, 0L );
fread( &c, 1, 1, f );
printf("%c", c );
fseek( f, gp, 0l );
fwrite( &c, 1, 1, f );
gp++;
}
printf(" ");
unique++;
}

int main ()
{
f = fopen( "f", "w+" );

Init();
Function();
fclose(f);

return 0;
}