Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main() {
- char strOne[20];
- char strTwo[20];
- gets(strOne); // input
- gets(strTwo);
- int check = strcmp(strOne, strTwo);
- if(check == 0) {
- printf("Both strings are same\n");
- } else if(check > 0) {
- printf("First string is greater than the sceond one\n");
- } else if(check < 0) {
- printf("Sceond string is greater than the first one\n");
- }
- // logic of finding length of a string
- // int i = 0;
- // int length = 0;
- // while (strOne[i] != '\0') {
- // length++;
- // i++;
- // }
- // printf("%d\n", length);
- // int lenOne, lenTwo;
- // lenOne = strlen(strOne);
- // lenTwo = strlen(strTwo);
- // printf("Length of strOne = %d\n", lenOne);
- // printf("Length of strTwo is = %d\n", lenTwo);
- // printf("Before Concat:\n");
- // printf("String One = %s\n", strOne);
- // printf("String Two = %s\n", strTwo);
- // strcat(strTwo, strOne);
- // strcpy(strThree, strTwo);
- // strcpy(strTwo, strOne);
- // printf("String Three = %s\n", strThree);
- return 0;
- }
- // int main() {
- // char str[20];
- // gets(str);
- // scanf("%s", str); // Input using scanf
- // printf("%s\n", str);
- // }
- /*
- '\0' -> null charachter
- 1. Basic Concepts about string in c.
- 2. Input a string.
- 3. Print a string.
- 4. Some functions related to string
- -> strcpy(one, two);
- -> strcat();
- -> strlen();
- -> strcmp();
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement