Odpowiedź z systemu

0

Witam!
Mam problem z odczytaniem zwrotu z funkcji system. Mam systemie komendę "GPIO read", która po wpisaniu w terminalu zwraca "0" lub "1". Chodzi o to, żeby móc zrobić coś w stylu

 if ( system("GPIO read")) printf("jest") else printf("nie ma")

mógłby ktoś podpowiedzieć jak to wykonać?

0

Jakiego zwrotu? http://www.cplusplus.com/reference/cstdlib/system/

If command is a null pointer, the function returns a non-zero value in case a command processor is available and a zero value if it is not.

If command is not a null pointer, the value returned depends on the system and library implementations, but it is generally expected to be the status code returned by the called command, if supported.

0

Chodzi o to, że po wpisaniu w terminalu komendy "GPIO read" system wyświetla w terminalu "1" lub "0" i chcę aby te "1" lub "0" odebrać bezpośrednio w kodzie programu. Chodzi o linuxa, jeśli to ma jakieś znaczenie.

0

windows czy linux?
Po podpowiedzi od @Lord Darkstorm w komentarzu: https://linuxprograms.wordpress.com/category/pipes/

0

Linux ;)

0

Nic mi to nie mówi niestety, zbyt skomplikowane jak na moją znajomość c++, ale dzięki :(

0

Przecież masz przykład.

1 użytkowników online, w tym zalogowanych: 0, gości: 1