Search code examples
cstrcmp

Is this the right statement for string comparison of two strings?


if(strcmp(p[pas].origin,"West")&&strcmp(p[pas].destination,"East")==0)
      {
       cost[pas]=5.62+5.62;
      }

is this the right code for the two input strings? or is there something wrong since the program runs but i cannot get the return value


Solution

  • Didn't run but should be like this

    if((strcmp(p[pas].origin,"West")==0) && (strcmp(p[pas].destination,"East")==0)
          {
           cost[pas]=5.62+5.62;
          }