use
system("sudo hciconfig hci0 piscan");
or
FILE *pipe;
pipe=popen("sudo hciconfig hci0 piscan", "r");
to get the output of your command from the pipe
, you can use the functions fgets
, fread
, ... you can read from the pipe like you read from a file