#include <stdio.h>
int main( void )
{
char ** firstNames;
char ** lastNames;
float * scores;
int recordsLength;
printf ( "Please indicate the number of records you want to enter: " ) ; scanf ( "%d" , & recordsLength
) ;
firstNames
= ( char ** ) malloc ( recordsLength
* sizeof ( char * ) ) ; lastNames
= ( char ** ) malloc ( recordsLength
* sizeof ( char * ) ) ; scores
= ( float * ) malloc ( recordsLength
* sizeof ( float ) ) ;
int i = 0 ;
while ( i < recordsLength)
{
createNewEntry( i, firstNames, lastNames, scores) ;
i++;
}
printEntry( 0 , firstNames, lastNames, scores) ;
return 0 ;
}
void clearScreen( )
{
#ifdef _WIN32
#elif _unix_
#endif
}
void printEntry( int entryID, char * firstNames[ ] , char * lastNames[ ] , float scores[ ] )
{
clearScreen( ) ;
printf ( "|-------------------------------------------------------------------------|\n " ) ; printf ( "| Student Entry |\n " ) ; printf ( "|-------------------------------------------------------------------------|\n |\n " ) ; printf ( "| First Name: %s Last Name: %s Score: %.1f\n |\n |\n |\n " , firstNames
[ entryID
] , lastNames
[ entryID
] , scores
[ entryID
] ) ; printf ( "|-------------------------------------------------------------------------|\n " ) ; printf ( "|-------------------------------------------------------------------------|\n \n " ) ; }
void createNewEntry( int index, char * firstNames[ ] , char * lastNames[ ] , float scores[ ] )
{
printf ( "Please input the records of the new student.\n \n \n " ) ; char first[ 20 ] ;
char last[ 20 ] ;
float score = 100.0f ;
printf ( "Please enter the student's first name: " ) ;
printf ( "Please enter the student's last name: " ) ;
printf ( "Please enter the student's score: " ) ;
firstNames
[ index
] = ( char * ) malloc ( 1 + ( strlen ( first
) ) * sizeof ( char ) ) ; strcpy ( firstNames
[ index
] , first
) ;
lastNames
[ index
] = ( char * ) malloc ( ( 1 + strlen ( last
) ) * sizeof ( char ) ) ; strcpy ( lastNames
[ index
] , last
) ; printf ( "first name: %s" , firstNames
[ index
] ) ; printf ( "last name: %s" , lastNames
[ index
] ) ; scores[ index] = score;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgbWFpbih2b2l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