From f97443db9348998f735093f7d752d867a371e5e9 Mon Sep 17 00:00:00 2001 From: "Gustavo \"Guz\" L de Mello" Date: Mon, 30 Mar 2026 16:25:51 -0300 Subject: [PATCH] feat(strings): ex2 --- strings/ex2.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 strings/ex2.c diff --git a/strings/ex2.c b/strings/ex2.c new file mode 100644 index 0000000..237358d --- /dev/null +++ b/strings/ex2.c @@ -0,0 +1,26 @@ +#include +#include +#include + +int main(void) { + + char str1[100], str2[100]; + + printf("Digite a primeira palavra: "); + fgets(str1, 100, stdin); + + str1[strcspn(str1, "\n")] = '\0'; + + printf("Digite a segunda palavra: "); + fgets(str2, 100, stdin); + + str2[strcspn(str2, "\n")] = '\0'; + + if (strcmp(str1, str2) == 0) { + printf("%s e %s são iguais.\n", str1, str2); + } else { + printf("%s e %s não são iguais.\n", str1, str2); + } + + return EXIT_SUCCESS; +}