So here I have
if(argv[0] == L"test") {
cout << "it is test";
}
else {
cout << "Nope."
}
And it always displays "Nope." I don't know what I'm doing wrong... I've tried using different ways but they all end up the same way.
So here I have
if(argv[0] == L"test") {
cout << "it is test";
}
else {
cout << "Nope."
}
And it always displays "Nope." I don't know what I'm doing wrong... I've tried using different ways but they all end up the same way.
A more C++ like solution would be:
#include <string>
#include <iostream>
using namespace std;
int main(int argc, wchar_t* argv[])
{
if (argv[0] == wstring(L"test")) {
cout << "it is test";
}
else {
cout << "Nope.";
}
return 0;
}
You can use wcscmp().
You're main function has to pass a wide character for argv[0] like so:
int main(int argc, wchar_t*argv[])
then you can do:
if (wcscmp(argv[0], L"test"))
You need to use strcmp
as argv
is an array of char*
.
Your code compares the pointers instead of the string content.