Reputation: 2233
It's been awhile (10+ years) since I've developed in C++. I am trying to accept a value via command line and pass it along to a class constructor.
#include "stdafx.h"
#ifdef _WIN32
#include <windows.h>
#include "WinFolderMonitor.h"
#elif __APPLE__
#elif __linux__
#elif __unix__
#endif
int main(int argc, TCHAR *argv[])
{
if (argc != 2)
{
_tprintf(TEXT("Usage: %s <dir>\n"), argv[0]);
return 0;
}
#ifdef _WIN32
WinFolderMonitor* folderMonitor = new WinFolderMonitor(argv[1]);
#endif
folderMonitor->WatchDirectory();
return 0;
}
However, the output I am getting is not as expected. Rather, I am receiving a bunch of question marks, which I would normally attribute to some encoding issue but I believe that I've set up the project correctly to mitigate that.
C:\SVN\monitor.exe
Usage: ?????????e????? <dir>
From my understanding, I should be seeing the application filename. But I am getting a whole bunch of question marks. I have setup my project to use "Unicode" within Visual Studio.
Upvotes: 1
Views: 1406
Reputation: 31619
Use _tmain
instead main
. If UNICODE is defined, _tmain
becomes a macro for wmain(int argc, wchar_t* argv[])
See also msdn:main
int _tmain(int argc, TCHAR *argv[])
{
if (argc != 2)
{
_tprintf(TEXT("Usage: %s <dir>\n"), argv[0]);
return 0;
}
return 0;
}
This is usually for homework purposes. There is no point to make this ANSI compatible unless you are also targeting Windows 98. Otherwise you can use UNICODE only version, for example const wchar_t *text = L"text";
etc.
Upvotes: 3