I am new to C programming and was wondering if anyone could give me a hint on why my program is acting up on repl.it, but not on CLion. It seems to have something to do with my return statement where I return smallest in my min function. However, I don't understand why it is working correctly on one IDE and not the repl.it IDE.
#include <stdio.h>
#include <string.h>
char *min(char *a, char *b, char *c);
int main(void) {
char apple[10] = "apple";
char boy[10] = "boy";
char zoo[10] = "zoo";
char smallest[10];
strcpy(smallest, min(apple, boy, zoo));
printf("The smallest string is %s", smallest);
return 0;
}
char *min(char *a, char *b, char *c) {
char smallest[10];
int firstResult = strcmp(a, b);
if (firstResult < 0) {
strcpy(smallest, a);
} else {
strcpy(smallest, b);
}
int secondResult = strcmp(smallest, c);
if (secondResult < 0) {
strcpy(smallest, smallest);
} else {
strcpy(smallest, c);
}
return smallest;
}