Question: I need help I am getting a warning: implicit declaration of function. I need to use printf_s, scanf_s and memcpy_s for security reasons. Can someone
I need help I am getting a warning: implicit declaration of function. I need to use printf_s, scanf_s and memcpy_s for security reasons. Can someone add what I'm missing to get this code to run correctly.
the code is below:
#include #include
enum { BUFFERSIZE = 15 };
// Function prototypes void fillPassword(size_t, char[]); void showResults(char); void showMenu(void);
// Define a variable to hold a password // and the copy char password[BUFFERSIZE] = ""; char cpassword[BUFFERSIZE] = "";
int main(void) { // Welcome the User printf_s("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 (cont != 'E' && cont != 'e') { // Display the Menu showMenu();
// Get the user selection scanf_s("%c", &cont, 1); //No user input accepted; just clears newline char getchar();
// Display the menu response showResults(cont); } // Call the Copy routine fillPassword(sizeof(password), password);
// Display variable values printf_s("password is %s ", password); printf_s("cVar is %d ", cVar); printf_s("Length of password is %d ", sizeof(password) - 1);
// Copy password memcpy_s(cpassword, sizeof(cpassword), password, sizeof(password));
// Pause before exiting printf_s("Press enter to confirm your exit!"); 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 - 1; j++) { dest[j] = '1'; } // Add null terminator for string dest[n] = '\0'; }
/* Display the Results*/ void showResults(char value) { switch (value) { case 'F': case 'f': printf("Welcome to the Football season! "); break; case 'S': case 's': printf("Welcome to the Soccer season! "); break; case 'B': case 'b': printf("Welcome to the Baseball season! "); break; case 'E': case 'e': printf("Exiting the Menu system! "); break; default: printf("Please enter a valid selection "); break; }
}
/* Display the Menu*/ void showMenu(void) { printf_s("Enter a selection from the following menu. "); printf_s("B. Baseball season. "); printf_s("F. Football season. "); printf_s("S. Soccer season. "); printf_s("E. Exit the system. "); }
Visual Studio gave me 14 errors. I got 4 warnings using Netbeans
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
