Hello. For this program I'm doing I'm trying to get a user to enter two words, have those words passed into a function which compares the two words and sets a char pointer to a certain sentence based on the comparison.
The error I'm getting is "too few arguments to function compare". Any idea what I'm doing wrong?
Code:
#include <stdio.h>
#include <string.h>
void compare(char string1[30], char string2[30]);
void main()
{
char string1[30];
char string2[30];
printf("Please enter a word.\n");
scanf("%s", string1);
printf("Please enter a second word.\n");
scanf("%s", string2);
compare();
}
void compare(char string1[30], char string2[30])
{
char *msg = NULL;
if(strcmp(string1, string2)>0)
{ msg = "First word is greater than the second."; }
else if(strcmp(string1, string2)<0)
{ msg = "Second word is greater than the first."; }
else
{ msg = "First word is equal to the second word."; }
printf("%s\n", msg);
}
Thanks!