Question: Does the below C code violate (FIO34-C. Distinguish between characters read from a file and EOF or WEOF.) if so can you explain why of

Does the below C code violate (FIO34-C. Distinguish between characters read from a file and EOF or WEOF.) if so can you explain why of why not? And if it does please provide a code example in a screen shot of the way you fixed the code.

#include

#include

// Function prototypes void fillPassword(size_t , char[]); void showResults(char); void printf_s_l();

// should have void listed void showMenu();

// Define a variable to hold a password // and the copy char password[15]; char cpassword[15]; int main(void)

{ // Welcome the User printf_s_l("Welcome to the C Array Program! ");

// Variables char cont = 'y'; // To continue with loop int cVar = 0; // process variable

// Display menu and Get Selection while (1)

{ // Display the Menu showMenu();

scanf("%c", &cont);

// Display the menu response showResults(cont);

// if user wants to exit if( cont == 'e' || cont == 'E' )

break;

// to get the next line character scanf("%c", &cont);

}

// Call the Copy routine fillPassword(sizeof(password),password);

// Display variable values printf("password is %s ", password); printf("cVar is %d ", cVar);

// Copy password memcpy(cpassword, password,sizeof(password));

// Pause before exiting char confirm;

printf("Confirm your exit!");

confirm = getchar();

return 0;

}

// Make a String of '1's void fillPassword(size_t n, char dest[]) { // Should be n-1 for (size_t j = 0; j < n; j++) { dest[j] = '1'; } // Add null terminator for string dest[n] = '\0'; }

/* Display the Results*/ void showResults(char value) {

switch (value){

case 'F': printf("Welcome to the Football season! "); break;

case 'f': printf("Welcome to the Football season! "); break;

case 'S': printf("Welcome to the Soccer season! "); break;

case 's': printf("Welcome to the Soccer season! "); break;

case 'B': printf("Welcome to the Baseball season! ");

break;

case 'b': printf("Welcome to the Baseball season! "); break;

case 'E': printf("Exiting the Menu system! "); break;

case 'e': printf("Exiting the Menu system! "); break;

default: printf("Please enter a valid selection ");

}

}

/* Display the Menu*/ void showMenu(void) {

printf("Enter a selection from the following menu. ");

printf("B. Baseball season. ");

printf("F. Football season. ");

printf("S. Soccer season. ");

printf("E. Exit the system. ");

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!