I wrote one simple function that should return wheather the two strings supplied by the user are identical.
Namely, it should return 1
if they are and 0
if they aren't.
Here is a simple runnable program with that function, please check it and point out what is wrong.
#include <stdio.h>
int compare_strings(char string0[], char string1[])
{
int success = 0;
if (sizeof(string0)/sizeof(char) == sizeof(string1)/sizeof(char))
{
success = 1;
for (int i = 0;i < sizeof(string0)/sizeof(char);i++)
{
if (string0[i] != string1[i])
{
success = 0;
break;
}
}
}
return success;
}
void main(int argc, char **argv)
{
if (argc >= 3)
{
int yes_or_no = compare_strings(argv[1], argv[2]);
if (yes_or_no == 0)
{
printf("FALSE\n");
}
else
{
printf("TRUE\n");
}
}
else
{
printf("I need at least two parameters!\n");
}
}