MinGW を使用して Windows からユーザー名を取得するには、unistd.h の getlogin() 関数または Windows 関数 GetUserName を使用する必要がありますか?
ありがとうございました。
USERNAME変数を確認できます:
char *name = getenv("USERNAME"); // Get environmentvariable for Username
if( name == NULL )
    return -1; // Username not found ...
else
    printf("%s\n", name); // Output Username
完全に Windows を使用している場合は、その API ( GetUserName()) も使用できます。
#include <windows.h>
#include <Lmcons.h>
// ...
TCHAR name [ UNLEN + 1 ];
DWORD size = UNLEN + 1;
if( GetUserName((TCHAR*) name, &size) )
    printf("%s\n", name); // Output Username
else
    return -1; // Username not found ...
getlogin()ている場合に使用してくださいGetUserName()ている場合に使用します