You still do not need a 2D char array for this (or two loops). There is something you are confused about.
This will do more or less what you are asking and might clarify some issues for you.
Code:
#include <stdio.h>
#include <string.h>
int sameWord(char *one, char *two) {
int len1=strlen(one), len2=strlen(two), i,j;
for (i=0;i<len1;i++) {
for (j=0;j<len2;j++) {
if (one[i]==two[j]) break;
if (j==len2-1) return 0; //end of "two", letter not found
}
}
return 1;
}
int main(int argc, char *argv[]) {
if (argc<3) {puts("Two words needed");return -1;}
if (sameWord(argv[1],argv[2])==1) printf("\"%s\" has the letters to spell \"%s\"\n",argv[2],argv[1]);
else printf("\"%s\" does not have the letters to spell \"%s\"\n",argv[2],argv[1]);
return 0;
}
Output:
Code:
./a.out this xchtsi
"xchtsi" has the letters to spell "this"
./a.out this xcgtso
"xchgso" does not have the letters to spell "this"