user975582
user975582

Reputation: 205

How do I pass an argument that was passed to main (in argv) to my function?

How can i pass argv[] to my function?, I am getting the errors when I run my program. I am new to c++ but i think i am not passing it right look at the error and my code. Now dont worry about the Depth First algorithm.. i will get to that later.. I am just trying to make this work.., basically I just want to pass the *argv[] to evaluate them in my printDepthFirst() but something is not right (obviously) .. Thank you

myprogram.c: In function ‘main’:
myprogram.c:18:4: warning: passing argument 1 of ‘opendir’ makes pointer from integer without a cast
/usr/include/dirent.h:135:13: note: expected ‘const char *’ but argument is of type ‘char

code

Upvotes: 0

Views: 183

Answers (1)

I think you meant to write opendir(arg_temp). arg_temp[1] is the second character of arg_temp. I wouldn't recommend using global variables to pass things to your function though anyway.

Upvotes: 2

Related Questions