It compiles properly but when I try to run it like this ./a.out trial.doc abc ('trial.doc' - argv[1] filename and 'abc' - argv[2] key)
it gives the following error - Segmentation fault (core dumped)
Now, I know this happens when we try to access memory that we can't. So, where am I going wrong here? I'm unable to figure out.
> Ok, so turns out I have only 1 parameter
I wonder how did you reach that conclusion...
I don't see you printing the number of parameters in your second and third test.
So, as expected, argv[1] is the filepath along with filename, argv[2] is the key. Then what is wrong? Which part of memory is inaccessible? Why am I still getting Segmentation fault(core dumped)?