Created
January 20, 2022 03:39
-
-
Save Alafun/37a77bf96da1cf310d97aaf93f643ffa to your computer and use it in GitHub Desktop.
To help me understand the way of using string.h library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<string.h> | |
int main() | |
{ | |
char c[20]; | |
char d[20]; | |
gets(c); | |
int i=0; | |
int j; | |
j=strlen(c); | |
for(i;i<strlen(c);i++) | |
{ | |
j--; | |
d[j]=c[strlen(c)-i-1]; | |
} | |
int result = strcmp(c, d); | |
if (result < 0) | |
{ | |
printf("%d\n",-1); | |
} else if (result > 0) | |
{ | |
printf("%d\n", 1); | |
} else { | |
printf("%d\n", 0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment