pointer comparision with int type in c++

  argv, c++

I executed the below program as: ./aout w.

#include<iostream>
using namespace std;

int main(int argc, char** argv)
{
    if (argv[1] == "w")
    {
        cout << "this was worked";
    }
    else
    {
        cout << "this did not worked";
    }
}

OUTPUT: this did not worked.
I tried executing: if(&argv[1] == "w")
if(argv[1]=='w')

Source: Windows Questions C++

LEAVE A COMMENT