Compare command line arguments to strings in c? for example I want just the word "autoplay" to be the command line argument, how can i validate that this is the only word? i already have it validating for more than 1 word.
if( argc == 2 ) {
autoplay(num5);
}
strcmp()to compare them.if (argc == 2 && strcmp(argv[1], "autoplay") == 0)for(int i = 0; i < argc; i++) if(strcmp(argv[i], "autoplay") == 0) autoplay(num5);?strcmp()doesn't return a boolean, it returns0when the strings match.if( argc == 2 )then there only is one argument. If can therefor only be the only word. So, either your question needs more explanation, or it is already solved by the code you have shown.