Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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...

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

What did you want to be when you were small?

Answered: 1 week ago