I am trying to implement some kind of a which program. I could get the PATH environment variable and was able to tokenize it. I have a list of paths in tokens[]. Now, I have the name of the shell command. How would I search the tokens[] and display where the command was found?
One weird thing is that when I try to print out the elements in the paths array, it says there are atleast 9 but when I use sizeof(paths) I get 4... What could be the reason for this?