CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2008
    Posts
    8

    If condition correct but the program go to else????

    Hi, I'm new here and need help with if problems.
    Code:
    int main(int argc, char *argv[])
    {
       list<char> charList;  
       vector<vectordata> myvector;     
    
       if (argc != 4) {
          printf("Syntax : euro file\n");
          return 0;
       }
       
       cout << argv[1];
       if ( argv[1] == "e" )
       {
       loadList2(charList, argv[2]);
       //printList(charList);
       loadList(myvector);
       encode(charList, myvector);
       printvectordata(vectorresult, argv[3]);
       return 0;
       }
       else
       {
       cout << "error" << endl;
       return 0;
       }
    }
    The debug code shown that argv[1] value e
    please help me
    thanks

  2. #2
    Join Date
    Sep 2007
    Posts
    7

    Re: If condition correct but the program go to else????

    maybe I am a bit daft, but isn't the proper syntax for making a comparison in an if statement for a character 'e' instead of "e"? or is that some special property of passing in a parameter through int main. I am rather unfamiliar with that.

  3. #3
    Join Date
    May 2008
    Posts
    8

    Re: If condition correct but the program go to else????

    Ok thanks it's sloved

  4. #4
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: If condition correct but the program go to else????

    Or use strcmp().

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured