To finish up this chapter, we will create a program that uses fgets() to get a list of names as input, sorts them into an array, and then prints the sorted array using fputs(). Create a file named nameSorter.c and begin by entering the following declarations, function prototypes, and the main() routine:
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
const int listMax = 100;
const int stringMax =80;
typedef char string [ stringMax ];
void addName(string* names , string newOne , int* listSize );
void printNames( string* names , int listSize );
void removeNewline( string s ) {
int len = strlen( s );
s[ len-1 ] = '\0';
}
int main( void ){
string newName;
string nameList[ listMax ];
intnumNames = 0;
while( printf( "Name: %d: ", numNames+1 ),
fgets( newName , stringMax , stdin ),
removeNewline( newName ) ,
strlen( newName ) > 0 )
addName( nameList , newName , &...