Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // g++ p1.cpp -o p1
- // ./p1
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <typeinfo>
- #include <cstdio>
- #include <iostream>
- #include <memory>
- #include <stdexcept>
- #include <string>
- #include <array>
- #include <cstring>
- #include <fstream>
- using namespace std;
- int main(){
- for(int i=1; i<5; i++){
- }
- echo("DONE");
- return 0;
- }
- /////////////////////////////////// LIBRARY ///////////////////////////////////////
- // functions RB
- void set(string pin, string val){
- system("gpio mode "+pin+" out");
- system("gpio write "+pin+" "+val);
- }
- string get(string pin){
- string a0 = run("gpio read "+pin);
- string a = a0.substr(0,a0.size()-1);
- return a;
- }
- // functions OGOLNE
- void typeVar(string var){
- cout << var + ": " + typeid(var).name() << endl;
- }
- void echo(string s){
- cout << s << endl;
- }
- // std:: -- usunalem przed deklaracją
- string run(const std::string& command) {
- system((command + " > t.txt").c_str());
- std::ifstream ifs("t.txt");
- std::string ret{ std::istreambuf_iterator<char>(ifs), std::istreambuf_iterator<char>() };
- ifs.close();
- if (std::remove("t.txt") != 0) {
- perror("Error deleting temporary file");
- }
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement