-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodify.cpp
46 lines (43 loc) · 1018 Bytes
/
modify.cpp
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
#include <fstream>
#include <iostream>
#include <ctime>
#include <ios>
#include <sys/stat.h>
using namespace std;
const std::string currentDateTime() {
time_t now = time(0);
struct tm tstruct;
char buf[80];
tstruct = *localtime(&now);
strftime(buf, sizeof(buf), "%Y-%m-%d.%X", &tstruct);
return buf;
}
int main(int argc, char *argv[])
{
if(argc>1)
{
ofstream outf("/home/gaurav/Desktop/command.txt",ios::out|ios::app);
for(int i=1;i<argc;i++)
{
char cwd[1024];
getcwd(cwd, sizeof(cwd));
outf<<"3\n"<<cwd<<"/"<<argv[i]<<"\n";
char str;
str=getchar();
while(str!=EOF)
{
outf<<str;
str=getchar();
}
outf<<"\n@#$%^&*\n";
}
outf<<currentDateTime()<<"\n";
outf.close();
printf("\nfile modified!\n");
}
else
{
printf("Filename missing!\n");
}
return 0;
}