0

I don't need help with the pset, since I have finished already. in , I was getting a segmentation fault. after changing argv[2] to argv[1], the problem was solved.

My question is: if I my command-line arguments are ./, caesar and key, why is my key is in argv[1] and not argv[2]?

1

in case you run your program as follows:

./caesar key

you have 2 command-line arguments (i.e., argv[0] containing the name of the executable, in this case ./caesar and argv[1] containing key). so yes, key in this case is the second argument.

the third argument, argv[2], in this case, is NULL according to the C standard. this is why you get a segmentation fault.

1
  • Ah I see, So I was making the mistake in thinking that './' is a command line argument but when I use './caesar' it's one command line argument and not two. Thank you very much for your help! – kamcho 56 Apr 16 '16 at 10:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .