Segmentation fault with strcmp()
问题 if(strcmp(argv[2], NULL) == 0) I'm passing 3 command line arguments but I also want to run it with only 2 command line arguments with the above statement. But a segmentation fault error is being displayed. I also tried with if(argc < 3) but it also didn't work...same segmentation fault... 回答1: Why segmentation fault? Because of code if(strcmp(argv[2], NULL) == 0) , you are passing NULL as string pointer to strcmp() function; that try to deference at NULL to compare chars codes (e.g. acsii