basics · beginner · ~15 min
Use the sign convention of strcmp.
Test two strings for equality using the standard strcmp.
Implement int str_eq(const char *a, const char *b) that returns 1 if a and b are equal, else 0. You may call strcmp (which returns 0 exactly when the strings match). No main — the grader calls it.
Two NUL-terminated strings a and b.
Returns 1 if the strings are equal, otherwise 0.
str_eq("abc", "abc") -> 1
str_eq("abc", "abd") -> 0
str_eq("", "") -> 1
Two NUL-terminated strings a and b.
1 if equal, otherwise 0.
Using strcmp is allowed.
#include <string.h>
int str_eq(const char *a, const char *b) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.