Open directory using C

后端 未结 4 1326
时光取名叫无心
时光取名叫无心 2020-12-03 01:55

I am accepting the path through command line input.

When I do

dir=opendir(args[1]);

it doesn\' t enter the loop...i.e dir==nu

4条回答
  •  爱一瞬间的悲伤
    2020-12-03 02:26

    Parameters passed to the C program executable is nothing but an array of string(or character pointer),so memory would have been already allocated for these input parameter before your program access these parameters,so no need to allocate buffer,and that way you can avoid error handling code in your program as well(Reduce chances of segfault :)).

提交回复
热议问题