-
Compare strings problem
This is my first time taking a computer science class, and Im having trouble with it. This problem is supposed to compare two or more arguments and the program will search the second and remaining arguments to compare to the first one. If one of them matches it will say match found, if it doesnt then no match found. This is what i have so far and would like some help/comments on it.
Code:
int main(int argc, char * argv[]){
char *p;
p = argv[1];
int x;
x = 2;
while (argc != x){
x = x + 1;
}
return 0;
if (strcmp(argc,x)==0){
printf("match found");
}
return 0;
else {
printf ("%s match not found %s");
}
return 1;
}
I appreciate the help.
-
The main function is returning right after the loop. Why (other than the fact that you put a return statement there)?
Quzah.
-
oh i see what you say. well i was working on it and up until the line that says "while" is right, i think?..from that on is all what i thought would work, obviously didn't.