As Dani's @ tinstaafl suggests ...
firstly ...
to get a design for just simple addition (of large int's of any size) to work,
you could use some functions to read in dynamic C strings of any size, maybe something like this:
Note that file "readLIne2.h" is available here:
http://developers-heaven.net/forum/index.php/topic,2582.msg3143.html#msg3143
/* add_dynamic_Cstrings.c */
#include "readLine2.h"
/* 2 handy utilities here ... */
int takeInChr( const char* msg )
{
char chr;
fputs( msg, stdout ); fflush( stdout );
chr = getchar();
if( chr != '\n' ) while( getchar() != '\n' ) ; /* flush stdin ... */
return chr;
}
int more() /* defaults to 'true'/'yes'/'1' ... unless 'n' or 'N' entered */
{
if( tolower( takeInChr( "More (y/n) ? " )) == 'n' ) return 0;
/* else ... */
return 1;
}
int is_valid( const char* str )
{
while( *str )
{
if( *str < '0' || *str > '9' ) return 0;
++str;
}
return 1;
}
char* add( const char* a, unsigned len_a, const char* b, unsigned len_b, unsigned* len_c )
{
char* c;
int i, j;
int overflow = 0;
if( len_a >= len_b )
{
c = newMem( len_a+1 );
c[len_a] = 0;
for( i = len_a-1, j = len_b-1; j >= 0; --i, --j )
{
c[i] = a[i] + (b[j] - '0') + overflow;
if( c[i] > '9' )
{
overflow = 1;
c[i] -= 10;
}
else
{
overflow = 0;
}
}
for( ; i >= 0; …