What is compilator doing ?

Hi guys. I'd like to know why when compiled this code needs to be run as administrator ?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include <iostream>
#include <string>
#include <cstdlib>
#include <windows.h>
#include <stdexcept>
#include <limits>
#include <Lmcons.h>
#include <fstream>
#include <stdio.h>


using namespace std;

template <class variable>
void out(variable x, bool y=false){if(!y){cout<<x;}else{cout<<x<<endl;}}

void outn(){out("");}
void delay(int x){Sleep(x);}
void delayS(int x){Sleep(x*1000);}
void cs(){std::system("cls");}

template <class U>
void odsc(U x,int y,bool z){out(x);delayS(y);z?cs():(void)(z=z);}

template <class T>
void input(T *x){T z;cin>>z;*x=z;}


void UserName(string *x){char username[UNLEN + 1];DWORD size = UNLEN + 1;GetUserName(username, &size);string transition(username);*x=transition;}
//use this syntax in main : string username;UserName(&username);

int main()
{
    const bool t=true;
    const bool f=false;


string username;
UserName(&username);
/*out(username);*/


    const string namefile="preferences.txt";


    string path;

    const string beginning="C:\\Users\\";
    const string ending="\\AppData\\Roaming\\Processing\\";

    path+=beginning;
    path+=username;
    path+=ending;

    string path2;
    path2=path;
    path2+="new.txt";
    string filename2="new.txt";

    path+=namefile;



    string line76="proxy.http.host=proxy-eple.in.ac-nantes.fr";
    string line77="proxy.http.port=3128";
    string line78="proxy.https.host=proxy-eple.in.ac-nantes.fr";
    string line79="proxy.https.port=3128";
    string line80="proxy.socks.host=proxy-eple.in.ac-nantes.fr";
    string line81="proxy.socks.port=3128";


    fstream file;
//fstream newfile;
    ofstream newfile/*(path2.c_str())*/;

try{file.open(path.c_str(),ios::in); if(!file.is_open()){throw 404;}}catch(int x){exit(x);}

if(file.is_open()){file.close();}

file.open(path.c_str());

try{newfile.open(path2.c_str(),ios::in); if(!newfile.is_open()){throw 404;}}catch(int x){exit(x);}

if(newfile.is_open()){newfile.close();}

newfile.open(path2.c_str(),ios::out|ios::trunc);

for(int i=1;i<97;i++){
    std::string z;

    std::getline(file,z);


    if( (i>=1&&i<76)||(i>=82&&i<97) ){newfile<<z<<endl;}

    if(i==76) newfile<<line76<<endl;
    if(i==77) newfile<<line77<<endl;
    if(i==78) newfile<<line78<<endl;
    if(i==79) newfile<<line79<<endl;
    if(i==80) newfile<<line80<<endl;
    if(i==81) newfile<<line81<<endl;
}
file.close();
newfile.close();
string old1 = beginning+username+ending+"old_pref.txt";


try{
int rf=rename(path.c_str(),old1.c_str());

if(rf!=0) throw 911;
}catch(int x){exit(x);}

try{
int rf2=rename(path2.c_str(),path.c_str());
if(rf2!=0) throw 911;
}catch(int x){exit(x);}



cs();


const int deleted = remove(old1.c_str());
try{if(deleted==0){odsc("All worked fine ! Old preferences file has been deleted and replaced by the new one ! ",5,t);}else{throw 43;}}catch(int x){exit(x);}

cs();

odsc("Modifications done!",5,t);

    return 0;
}
Topic archived. No new replies allowed.