-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathssh-converter.cpp
More file actions
34 lines (27 loc) · 768 Bytes
/
ssh-converter.cpp
File metadata and controls
34 lines (27 loc) · 768 Bytes
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
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
int main() {
string username;
cout << "Enter your username: ";
cin >> username;
string path = "C:\\Users\\" + username + "\\.ssh\\config";
string tempPath = "C:\\Users\\" + username + "\\Desktop\\config";
string search = "C:\\Users\\" + username;
string replace = "~";
ifstream file(path);
ofstream temp(tempPath);
if (file.is_open()) {
string line;
while (getline(file, line)) {
while (line.find(search) != string::npos) {
line.replace(line.find(search), search.length(), replace);
}
temp << line << endl;
}
}
file.close();
temp.close();
return 0;
}