I am pretty new to this, and am currently lost on this. I've tried several things, but I just cannot get it to work.
The program works for the most part: for instance, if I type Dog as my argument, Deadlift and Dumbbell will appear; however, it will also say that no word begins with the letter D. The second if statement is appearing regardless, even if there is a word in my array with the same first letter.
*confused*
Code:
#include <stdio.h>
#define WORDS 5
int main(int argc, char *argv[])
{
char list[WORDS][40]={"Deadlift", "Squat", "Lunge", "Dumbbell", "Press"};
int i, j;
for (i=1;i<argc;i++)
{
for (j=0;j<WORDS;j++)
if (argv[i][0] == list[j][0])
{
printf("%s starts with the same letter\n", list[j]);
}
if (argv[1][0]!=list[1][0])
{
printf("No letters begin with %s \n", argv[i]);
}
}
return 0;
}
Any help would be amazing!