void getString( char* pBuf,int maxLen )
{
char c = 0;
int index = 0;
for ( ; index < maxLen && c != '\n'; index ++ )
{
c = getchar();
*( pBuf + index ) = c;
}
*( pBuf + index ) = 0;
}
this is where the problem is
void reverseString( char* pBuf )
{
//get size of string
int index = 0;
for ( ; *pBuf != 0; index ++ );
index --;
//create internal buffer
char Buffer2[ 100 ];
for ( int a = 0; a < 100; a ++ )
{
Buffer2[ a ] = 0;
}
//store reverse into internal buffer
char size = index;
for ( ; index != 0; index -- )
{
Buffer2[ size - index ] = *( pBuf + index );
}
//copy internal buffer into main buffer
for ( char i = 0; i < 100 && Buffer2[ i ] != 0; i ++ )
{
*( pBuf + i ) = Buffer2[ i ];
}
}
this is the main
include <stdio>
void main()
{
char Buffer[ 100 ];
getString( &Buffer[ 0 ],100 );
putString( "\nthis is what you have just written: " );
putString( &Buffer[ 0 ] );
putString( "\nand this is the reverse of it: " );
reverseString( &Buffer[ 0 ] );
putString( &Buffer[ 0 ] );
}