Hello Guys! Super Beginner here! I just want to ask about sorting letters in a string. So below is the code that i've done. Can you help me on sighting errors that unable the program to sort letters in the string as well as on the predefined functions that i've used. I think, i've used these said functions improperly. Thanks in advance ^_^ and Godbless!
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#define s scanf
#define p printf
int check();
int check2();
char first[10];
char second[10];
char retry,temp;
int st1, st2,a,b;
int main()
{
p("\n\n\n\t\t\t A N A G R A M C H E C K E R \n");
p("\t_________________________________________________________________\n");
puts("\nEnter First Word: ");
gets(first);
puts("\nEnter Second Word: ");
gets(second);
check();
first[10]=check();
second[10]=check2();
p("\n\n _______________________________________________________________\n RESULT:");
{
if (stricmp(first,second)==0)
{
p (" %s and %s are Anagram Words!", first, second);
}
else
{
p (" %s and %s are Not Anagram Words!", first, second);
}
}
p ("\n\n **Retry the Program? [Y/N]: ");
s ("%s", &retry);
retry= toupper(retry);
{
if (retry=='Y')
{
main();
}
else
{
system ("pause");
}
}
getch ();
return 0;
}
int check()
{
strlen(first)==st1;
for (a = 0; a < st1-1; a++)
{
if (first[a] > first[a+1])
{
temp = first[a+1];
first[a+1] = first[a];
first[a] = temp;
a = -1;
}
else
{
continue;
}
}
return(first[10]);
}
int check2()
{
strlen(second)==st2;
for (a = 0; a < st2-1; a++)
{
if (second[a] > first[a+1])
{
temp = second[a+1];
second[a+1] = second[a];
second[a] = temp;
a = -1;
}
else
{
continue;
}
}
return(second[10]);
}