69 lines
2.0 KiB
C++

#include <pthread.h>
#include <sys/sysinfo.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <list>
#include <cstring>
void menu(){
std::cout << "1. Zamenjaj argumente\n";
std::cout << "2. Pridobi stanje\n";
std::cout << "3. Izklopi streznik\n";
std::cout << "4. konec\n";
std::cout << "Izbira: ";
}
int main(){
int izbira, l;
int runn = 1;
int arry[2];
int cev1, cev2, cev3;
int closep = 6;
unsigned long array[100];
while (runn == 1)
{
menu();
std::cin >> izbira;
switch (izbira){
case 1:
std::cout << "Vspisi dely v sekundah: ";
std::cin >> arry[0];
std::cout << "Vspisi stevilo branj: ";
std::cin >> arry[1];
cev1 = open("vhod", O_WRONLY);
write(cev1, &arry, sizeof(arry));
close(cev1);
break;
case 2:
cev2 = open("izhod", O_RDONLY);
if(cev2 < 0) std::cout << "tezava pri odpiranju cevi 0\n";
l = read(cev2, &array, sizeof(array));
if(l<0) std::cout << "tezava pri branju cevi \n";
for (int i = 0; i < 100; i += 5){
if(array[i] != 0)
std::cout << array[i] << " " << array[i+1] << " " << array[i+2] << " " << array[i+3] << " " << array[i+4] << "\n";
}
std::cout << "\n";
if(close(cev2) != 0) std::cout << "tezava pri zapiranju cevi 0\n";
break;
case 3:
cev3 = open("izklop", O_WRONLY);
write(cev3, &closep, sizeof(closep));
close(cev3);
runn = 0;
break;
default:
runn = 0;
break;
}
}
return 0;
}