0

Hi, I'm new here and need help with if problems.

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
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by handytxg
0

You cannot compare character strings in this manner. You need to use one of the string functions.

You probably want if ( strcmp(argv[1], "e") == 0 )

0

Ok thanks....it's sloved by change the "e" with 'e' and add pointer to *argv[1]
thanks

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.