hey i hope that someone here can help my with my question. in my homework I was asked to write a code that receives from the user 10 strings in size 10 Into an array of strings that will act like a dictionary. for example if the user enter bbb , ccc , abc , acb. the code will print abc acb bbb ccc. in our last lesson we learned about strcmp so i thought to use it here. this is what i got i know its worng but i have no idea what else to do so i hope someone here can help me. the code:
#include <stdio.h>
#include <string.h> int main() {
int i;
int j;
int index;
char a_word[10][10];
printf("Enter string:\n");
for (i = 0; i < 10; i++)
{
scanf("%s[^\n]", a_word[i]);
}
i = 0;
j = 1;
while (index<10)
{
if (strcmp(a_word[i], a_word[j]) == -1)
{
j++;
index++;
}
else if (strcmp(a_word[j], a_word[i]) <= 0)
{
i++;
index++;
}
}
if (strcmp(a_word[i], a_word[j]) <= 0)
{
printf("%s",&a_word[i]);
}
else if (strcmp(a_word[j], a_word[i]) <= 0)
{
printf("%s",&a_word[j]);
}
return 0;