如果您在 VC++ 中编译此代码,我有一个关于 VC++ 的问题:
#include "stdafx.h"
#include <stdlib.h>
//#include <stdio.h>
#include <iostream>
#include <Windows.h>
TCHAR lpBuffer[MAX_PATH];
int _tmain(int argc, _TCHAR* argv[])
{
DWORD dwBufferLength = 0;
if(!(dwBufferLength = GetWindowsDirectory(lpBuffer, MAX_PATH)))
std::cout << "Last error : "<< GetLastError() << std::endl;
else{
std::cout << lpBuffer << std::endl;
/*for(DWORD i = 0; i < dwBufferLength; i++)
printf("%c", lpBuffer);*/
std::cout << std::endl;
}
system("PAUSE");
return 0;
}
我只看到“C”,如果我用 g++ 编译它,我会看到“C:\Windows”有什么问题?当然我应该删除g ++下的第一行“#include“stdafx”:)
并将“_tmain”更改为“main”^__^