Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main()
- {
- char str1[50], str2[50];
- int str1Cntr=0, str2Cntr=0;
- int compare;
- printf("Enter a word1: ");
- scanf("%s",str1);
- printf("Enter a word2: ");
- scanf("%s",str2);
- //to get the legth of the strings
- str1Cntr = strlen(str1);
- str2Cntr = strlen(str2);
- //concatenate the two string using strcat
- strcat(str1,str2);
- // comparing both the strings using strcmp() function
- compare = strcmp(str1,str2);
- //display the legth of string 1 and 2
- printf("\nThe length of the first string is: %d", str1Cntr);
- printf("\nThe length of the second string is: %d", str2Cntr);
- //display concatenate the two string
- printf("\nConcatenated two String: %s\n", str1);
- //display if the string is equal
- if(compare==0) {
- printf("strings are equal");
- }
- else{
- printf("strings are not equal");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement