xxxxxxxxxx
#include <iostream>
using namespace std;
int main() {
system("python3 test.py");
return 0;
}
xxxxxxxxxx
#include <iostream>
using namespace std;
int main() {
system("DATE");
return 0;
}
xxxxxxxxxx
//----------------------------------
// CREDIT: gregpaton08 on stack overflow
// https://stackoverflow.com/questions/478898/how-do-i-execute-a-command-and-get-the-output-of-the-command-within-c-using-po
//----------------------------------
#include <cstdio>
#include <iostream>
#include <memory>
#include <stdexcept>
#include <string>
#include <array>
std::string exec(const char* cmd) {
std::array<char, 128> buffer;
std::string result;
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
if (!pipe) {
throw std::runtime_error("popen() failed!");
}
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
result += buffer.data();
}
return result;
}
xxxxxxxxxx
#include <iostream>
using namespace std;
int main() {
int age = 18;
if (age >14) {
if (age >=18) {
cout << " Adult";
}
else {
cout << "teeneger";
}
} else {
if (age >0) {
cout <<"child";
}
else {
cout << "something wrong";
}
}
return 0;
}
xxxxxxxxxx
#include <iostream>
using namespace std;
int main() {
system("DATE");
return 0;
}