feat(strings): ex2
This commit is contained in:
26
strings/ex2.c
Normal file
26
strings/ex2.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user