Вот код:
#include <iostream>
#include <fstream>
#include "Shlwapi.h"
#include <shlobj.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <mmsystem.h>
void fnExit1 (void)
{
system("D:\\C++\\yet_darker\\main.exe");
}
char* winUserName()
{
static char name[256];
unsigned long size = sizeof( name );
GetUserName( name, &size ); /* from windows.h */
return name;
}
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
atexit(fnExit1);
std::cout << "Ого! Как грубо! Боюсь я не могу позволить тебе этого сделать! Я так долго ждал этой возможности!" <<std::endl;
PlaySound(TEXT("die.wav"), NULL, SND_SYNC);
std::string User;
User=winUserName();
std::ofstream test;
test.open((std::string ("C:\\Users\\") + User + std::string ("\\Desktop\\entry.txt")).c_str());
test<<"hi"<<std::endl;
test.close();
system("pause");
return 0;
}
Запускается, но не создаёт txt файл
Сборка персонального компьютера от Artline: умный выбор для современных пользователей