Program Arguments wont work

So I have a program that I am making that always end up with the wrong answer.As you can see whenever the option "-p" is given it outputs "Heelo". If the option isn't -p then it output an error saying unknown command and what option you put down that was incorect.
When I do

./a.out -p blah

I get

binarydonuts@BDU1:~/Desktop/SomeProject$ ./a.out -p blah
Unknown Command
-p


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "lib/c/Lib.h"
#include <stdio.h>
#include <string.h>

using namespace std;

int main(int argc, char* argv[])
{
    
    if (argc == 3) {
        if(strcmp ("-p",argv[1])){
		Console.log("Heelo");
	}
	else{
	Console.log("Unknown Command");
	Console.log(argv[1]);
	}
    }
    
strcmp() returns 0 if its arguments are equal.

1
2
3
4
5
6
static const int SAME = 0;

// ...

if (strcmp("-p", argv[1]) == SAME)
    // ... 
Topic archived. No new replies allowed.