-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy path19_compare_pre_def.c
33 lines (26 loc) · 1.02 KB
/
19_compare_pre_def.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// // Write a c program to compare two strings using pre-defined function.
// // Header Files
#include <stdio.h>
#include <conio.h>
#include <string.h>
#define ARRAY_SIZE 31
// // Main Function Start
int main()
{
char str1[ARRAY_SIZE], str2[ARRAY_SIZE];
puts("\n>>>>>>> Enter Two Strings to Check Whether Both Are Equal or Not <<<<<<<<<");
printf("\nEnter First String (MAX CHARACTERS %d) => ", ARRAY_SIZE - 1);
fgets(str1, ARRAY_SIZE, stdin); // // Input String
str1[strcspn(str1, "\n")] = '\0'; // // Replace '\n' character with '\0' in str1
printf("\nEnter Second String (MAX CHARACTERS %d) => ", ARRAY_SIZE - 1);
fgets(str2, ARRAY_SIZE, stdin); // // Input String
str2[strcspn(str2, "\n")] = '\0'; // // Replace '\n' character with '\0' in str2
if (strcmp(str1, str2))
printf("\nNo, \"%s\" and \"%s\" Are Not Equal...", str1, str2);
else
printf("\nYes, \"%s\" and \"%s\" Are Equal...", str1, str2);
putch('\n');
getch();
return 0;
}
// // Main Function End