about the salary, I understand what you mean but the program is just for testing. I coded a function showed below.
Code:
//in main
char *name;
name = getString( 50 );
This is the function that returns a pointer to a character.
Code:
char *getString( int strSize )
{
char value;//, arrValue[ strSize ];
char *rcvValue;
int ctr = 0;
//rcvValue = arrValue;
rcvValue = malloc( 5 * sizeof( strSize ) );
while( 1 )
{
value = getch();
if( value == '\b' && ctr > 0 )
{
putch( value );
putch( ' ' );
putch( value );
ctr--;
}
else if( value != '\b' && value != '\r' && ctr != 30 )
{
if( isspace( value ) || isalpha( value ) )
{
//arrValue[ ctr ] = value;
rcvValue[ ctr ] = value;
putch( value );
ctr++;
}
}
if( value == '\r' )
{
if( ctr > 0 )
break;
}
}
rcvValue[ ctr ] = '\0';
//arrValue[ ctr ] = '\0';
//rcvValue = malloc( strlen( arrValue ) + 1 );
return rcvValue;
}
Maybe with this style of inputting string can avoid excess buffer coz I am able to restrict the user as you can see in the function. If you have any feedback with the code let me know.