#include <iostream>
#include <string>
#include <xmemory>
#include <stdio.h>
#define SSID_LEN 5
using namespace std;
string exec(const char* cmd) {
char buffer[128];
string result = "";
FILE* pipe = _popen(cmd, "r");
if (!pipe) throw runtime_error("popen() failed!");
try {
while (fgets(buffer, sizeof buffer, pipe) != NULL) {
result += buffer;
}
}
catch (...) {
_pclose(pipe);
throw;
}
_pclose(pipe);
return result;
}
int main() {
string a = exec("netsh wlan show int");
string b = "SSID";
string c = "BSSID";
string d = a.substr(a.find(b), a.find(c) - a.find(b));
string::iterator end_pos = remove(d.begin(), d.end(), ' ');
d.erase(end_pos, d.end());
string e = d.substr(SSID_LEN);
cout << "Wi-Fi adi: " << e << endl;
return 0;
}