I want to short string in Alphabetical Order
Code:
#include <stdio.h> int main(void)
{
char string[10] [10], temp;
int i, j, n;
printf ("\n Pramot user to Enter size: ");
scanf ("%s", &n);
for (i = 0; i < n; i++)
{
printf ("\n Enter the string: ");
scanf ("%s", &string[i]);
}
for(i = 0;i < n;i++)
{
for( j = i; j < n; j++)
{
if(strcmp(string[i],string[j])>0)
{
strcpy(temp,string[i]);
strcpy(string[i],string[j]);
strcpy(string[j],temp);
}
}
}
for(i=0;i<n;i++)
printf("%s ",string[i]);
return 0;
}
hello.c: In function 'main':
hello.c:21:17: warning: implicit declaration of function 'strcmp' [-Wimplicit-function-declaration]
if(strcmp(string[i],string[j])>0)
^~~~~~
hello.c:23:16: warning: implicit declaration of function 'strcpy' [-Wimplicit-function-declaration]
strcpy(temp,string[i]);
^~~~~~
hello.c:23:16: warning: incompatible implicit declaration of built-in function 'strcpy'
hello.c:23:16: note: include '<string.h>' or provide a declaration of 'strcpy'
hello.c:23:23: warning: passing argument 1 of 'strcpy' makes pointer from integer without a cast [-Wint-conversion]
strcpy(temp,string[i]);
^~~~
hello.c:23:23: note: expected 'char *' but argument is of type 'char'
hello.c:25:33: warning: passing argument 2 of 'strcpy' makes pointer from integer without a cast [-Wint-conversion]
strcpy(string[j],temp);
^~~~
hello.c:25:33: note: expected 'const char *' but argument is of type 'char'
What's the wrong