hello i hope for some help with my code.
i need to write code that recive 10 string from the user and sort them in alphabetical order and if the string that the user enter is lower the 10 letters i need to complete the word he enter with **** for exmaple:
“enter string”
abcd , aaaaaa.
printf:
aaaaaa***
abcd*****
explanation:
i sort the strings in alphabetical order
in the first string it was only 6 Letters so i add 3 ***
in the second string it was only 4 Letters so i add 5**
i was able to write the code but i do it in two different codes and i dont know how to connect them
first : the code that sort in alphabetical order
the second code that add *** if there is less than 9 word
I really hope that someone here can help me to connect this two codes
i need to write code that recive 10 string from the user and sort them in alphabetical order and if the string that the user enter is lower the 10 letters i need to complete the word he enter with **** for exmaple:
“enter string”
abcd , aaaaaa.
printf:
aaaaaa***
abcd*****
explanation:
i sort the strings in alphabetical order
in the first string it was only 6 Letters so i add 3 ***
in the second string it was only 4 Letters so i add 5**
i was able to write the code but i do it in two different codes and i dont know how to connect them
first : the code that sort in alphabetical order
C:
#include <string.h>
#include <stdio.h>
int main(){
int i,j;
char word[10][10],s[10];
printf("Enter string:\n");
for(i=0;i<10;i++)
{
scanf("%s",word[i]);
}
for(i=0;i<10;i++)
{
for(j=i+1;j<10;j++)
{
if(strcmp(word[i],word[j])==1)
{
strcpy(s,word[i]);
strcpy(word[i],word[j]);
strcpy(word[j],s);
}
}
}
i = 0;
while (i<10)
{
printf("%s \n",word[i]);
i++;
}
return 0;
}
the second code that add *** if there is less than 9 word
C:
#include <stdio.h>
int main()
{
int i = 0;
printf("enter string \n");
char word[10] = {};
scanf("%s", word);
while (i < 9)
{
if (word[i] == '\0')
word[i] = '!';
i++;
}
printf("%s", word);
return 0;
}
I really hope that someone here can help me to connect this two codes