Thread: Compare strings problem

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    9

    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.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    The main function is returning right after the loop. Why (other than the fact that you put a return statement there)?


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    9
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with comparing strings!
    By adrian2009 in forum C Programming
    Replies: 2
    Last Post: 02-28-2009, 10:44 PM
  2. Delphi DLL Problem, C++ hates Delphi strings
    By Cogman in forum C++ Programming
    Replies: 5
    Last Post: 09-08-2008, 07:32 PM
  3. problem with strings
    By agentsmith in forum C Programming
    Replies: 5
    Last Post: 04-08-2008, 12:07 PM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. Storing strings in 2d char arrays problem
    By rainmanddw in forum C++ Programming
    Replies: 5
    Last Post: 10-22-2003, 05:41 PM