简体   繁体   中英

How to know if a package is installed in Linux using C

I am creating an alarm clock for my project in C. I am using mgp123 command(in package mpg321) to run the alarm sound. It is only for UBUNTU users.I need the program to check whether mpg321 is installed or not. How can i find using C if the package mpg321 is installed using C program?

you can use system()

system("mpg321 -h");

if the command return error than the mpg321 is not installed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM