This code should compile without errors you should link -lcomdlg32 for dialogs. The program returns: 0x22fcd8 or 68 if I use pointer. And should (I think) return the name of the file user types in dialog box.
#include <windows.h>
#include <iostream>
int main() {
wchar_t szFileName[MAX_PATH] = {0};
OPENFILENAMEW ofn;
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFile = szFileName;
GetSaveFileNameW(&ofn);
using namespace std;
cout << szFileName << endl;
cout << *szFileName << endl; // also a number not a string
}
You have to use
wcoutif you want to output an array ofwchar_tas a null-terminated wide string.