Question: Given the following starter code: #include /* function declarations - CS 50 Students need to implement this function */ /* from the string argument, it
Given the following starter code:
#include /* function declarations - CS 50 Students need to implement this function */ /* from the string argument, it should return one of the following: */ /* 0 - name looks good!, as in "Howard Stahl" */ /* 1 - name has numbers in its value, as in "How123 Sta12" */ /* 2 - name has non-capitalized letters after a space, as in */ /* "howard stahl" */ /* 3 - name has non-capitalized letter as the first letter, as */ /* in "howard Stahl" */ /* 4 - name has non-alphanumeric characters, as in "#$5 Stahl" */ int validateName( char arr[] );
int main () {
/* a string to hold 100 characters */ char data[ 100 ]; int value; printf( "Please enter your name: " ); fgets( data, 100, stdin );
/* or alternatively if you are using a Mac... */ /* #include */ /* char * data = (char *) malloc( 100 * sizeof( char ) ); size_t bufsize; getline(&data,&bufsize,stdin); */ value = validateName( data ); switch( value ) { case 0: printf( "name passed all validation rules! " ); break; case 1: printf( "name has numbers, not only letters... " ); break; case 2: printf( "name has a letter following a space that is not capitalized... " ); break; case 3: printf( "name value does not start with a capital letter... " ); break; case 4: printf( "name has non-alphanumberic characters... " ); break; } return 0; } Please complete the declared function that have been stubbed out. By doing so, you will be working with strings and string arguments. I have supplied some sample output to help you understand the kind of code I am looking for.
SAMPLE RUN
Please enter your name: Howard Stahl name passed all validation rules!
Please enter your name: 124%%$ 1347DD name has numbers, not only letters...
Please enter your name: howard stahl name does not start with a capital letter...
Please enter your name: (*&)_#$% name has non-alphanumeric characters...