And now the little test program for the above new takeIns ...
/* test_takeIns.h.c */ /* 2015-04-08 */
#include "takeIns.h" /* includes readLine.h */
int main()
{
do
{
int ival = 0;
unsigned uval = 0;
float fval = 0;
double dval = 0;
char* sval = takeInStrLenInRange( "Enter a line of text : ", 5, 10 );
printf( "You entered '%s', with strlen = %u and my_strlen = %u\n",
sval, (unsigned)strlen(sval), (unsigned)my_strlen(sval) );
free( sval );
ival = takeInStrInt( "Enter an integer : " );
printf( "You entered: %d\n", ival );
uval = takeInStrUns( "Enter an unsigned integer : " );
printf( "You entered: %u\n", uval );
fval = takeInStrFlt( "Enter a float decimal value : " );
printf( "You entered: %e\n", fval );
dval = takeInStrDbl( "Enter a double decimal value : " );
printf( "You entered: %e\n", dval );
ival = takeInStrIntInRange( "Enter an integer in range 10..100 : ",
10, +100 );
printf( "You entered: %d\n", ival );
dval = takeInStrDblInRange( "Enter a double decimal value in range -100.1..+100.1 : ",
-100.1, 100.1 );
printf( "You entered: %e\n", dval );
}
while( more() );
return 0;
}