The main function when loaded (executed) is passed two arguments, an int and an an array of strings. The first entry in the array holds the path to the program that is executing. This string is passed from main to our setPaths function as the parameter pathName. An example of the string held in pathName is
/cygdrive/c/OpenGLTutorials/Examples/Chapter 9/ModelViewer
We first strip from this string the first 10 characters with the call
pathName.substr(10, pathName.length());
and reset pathName with this substring. The first two characters in the substring is the drive followed by a slash (c/ in the above example). But to use it, we need to have c:/. Thus, we start our modelPath with the string
pathName.substr(0,1) + ":/"
Next, since we know that the parent directory of the executable and all resources (the obj files include), we extract from pathName the substring following c/ and upto and including the parent directory (OpenGLTutorials in this example). Now we can add to our modelPath this substring and the sequence of folder names that conclude with the folder holding the obj files. In particular, we append the necessary text with the following
modelPath += pathName + "/Resources/WaveFront/";
Last, we need to store the path in an array of char and terminate the array with the null character.