After starting caesar with an additional argument and providing the sentence that needs to be encrypted, the Terminal shows this response:

jharvard@appliance (~/Dropbox/pset2): ./caesar 1


Segmentation fault (core dumped)
  • I removed your link (it's weird I am able to do...) because it gave the answer to the pset and it is strictly forbidden according to academic honesty rules.
    – ItsEric
    Jun 11, 2014 at 15:41
  • Thanks eric ur a good guy Jun 16, 2016 at 10:48

3 Answers 3


You should just run make caesar! :)

Edit: Since you edited your question to a completely different one, a segmentation fault happens when you touch a memory location that you shouldn't touch. It's hard to tell what exactly causes this without seeing your code, but more likely is that you're passing a string instead of a char to a function that accepts a char (e.g., isalpha())

  • I had the same issue, you were correct about passing a string vs char, solved it for me.
    – user11579
    May 28, 2016 at 6:51

Have you tried using GDB? With that you will be able to see exactly which command causes the seg fault, and then you can begin to work out why.

Common reasons would be accessing memory you shouldn't and passing NULL to a function as an argument.

But until you know which bit of code caused the seg fault you won't find out why it did.

Watch all the shorts and walkthroughs, pretty much everything you need to know is in these.


Segmentation fault occurs when accessing the supposedly not accessible chunks of memory. You might have declared the result variable in string and may have initialized to NULL..Instead you can try using array of char..like char[] and store your results. This is just a hint. After all you have to try it for yourself. As other responders suggested, do watch the shorts and walk-through, they are most helpful!

  • I tried using char for the text because I was getting the "segmentation error". But I encounter a strange (for me) problem. For example: if I use sth like char* cipher = (and then some text i add before executing the program to see if it works), the program works fine. But if I try with char* cipher[]=getchar(), i get a lot of errors. I guess the problem is that I don't use correctly the array of chars but I cannot find the error. i tried a lot of variations. Maybe the way to use an array of chars is not a one-line code?
    – GiP
    Nov 22, 2014 at 16:20

You must log in to answer this question.

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