I am checking argc because the first argument is fixed. The console aplication is called by another application. The calling application checks that there should be two parameters being passed to the console application. argv is a fixed parameter and argv is the filepath. If this is not the case then the calling application does not call the executable. That is why i am checking argc and i cant control the input argument to be in qoutes.
In reply to tsagld who wrote:
Realize that your code only works if the path is the last argument in the list. Besides that, you have to allocate space for cdrpath before you know how much space is needed. That's vulnerable to buffer overflows.
As I stated before, it is better to pass the path between double quotes. Stober gave an example.