vendredi 6 octobre 2017

Why is my if/else statement not ever going to else?

Im trying to write a program that takes in an argument(file name) from the command line. If it's not one of the four files that I expect then I want to print out that the correct file isn't found then exit safely. Right now when I run my code no matter what the argument is it will always run the printf("\n\n %s \n\n", argv[1]); line. Why is this happening?

int main(int argc, char **argv)
{
if(argv[1] == "orlando.csv" || "orlando5.csv" || "florida.csv" || 
"twolines.csv"){
    printf("\n\n %s \n\n", argv[1]);
} else {
    printf("etl ERROR: File %s not found", argv[1]);
    return -1;
}
}

Aucun commentaire:

Enregistrer un commentaire