I have no clue why I am getting this warning when my variable and return value match. I have pasted below the variable, assignment of that variable to a function and the function itself (return value and all)
char * menuMsg; /* used to print menu options */
menuMsg = printMenu();
char * printMenu()
{
static char message[250] = "Select an option from below:\n";
strcat(message, "(1) List all files on server\n");
strcat(message, "(2) Retrieve file from server\n");
strcat(message, "(3) Retrieve all files from server\n");
strcat(message, "Enter your selection: ");
return message;
}
Any clues as to why i would be receiving this error? To me they all line up it terms of type declarations.
This happens because you're calling the function before it's declared. Undeclared functions are assumed to return int, which explains the error.
Move the printMenu() definition to before the function that's doing the call, or add a prototype:
char * printMenu(void);
And make sure you add void, () is wrong for a function accepting no parameters.
Also, your code is broken since each time you call printMenu() it will call strcat() four times, causing the menu text to grow and grow and eventually cause a buffer overrun.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With