Skip to content

Instantly share code, notes, and snippets.

@Alafun
Created January 20, 2022 03:39
Show Gist options
  • Save Alafun/37a77bf96da1cf310d97aaf93f643ffa to your computer and use it in GitHub Desktop.
Save Alafun/37a77bf96da1cf310d97aaf93f643ffa to your computer and use it in GitHub Desktop.
To help me understand the way of using string.h library
#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