I'd like to find if the program less is installed on the system. I'm not allowed to use a direct system("which less") because of my requirements. So I'm going to try the PATHs in the PATH variable and do stat on the files to see if less is installed. But how do I append less to each of my PATHs? I started with this code
pathValue = getenv ("PATH");
if (! pathValue) {
printf ("'%s' is not set.\n", "PATH");
}
else {
printf ("'%s' is set to %s.\n", "PATH", pathValue);
}
Now it correctly prints my PATH but I don't know how to proceed. Can you help me? I think that I must tokenize my pathValue, how can I do that?
$ ./a.out 'PATH' is set to /home/developer/google-cloud-sdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games.