-5

I would like to know what that means, Im doing a program with matrix, kinda like pacman, but whenever I try to interact with the program it ends and returns "Exit status 42"

Johan
  • 41
  • 1
  • 4
  • 7
    The Answer to the Ultimate Question of Life, The Universe, and Everything – George Sep 18 '19 at 21:50
  • 2
    You are the victim or somebody's practical joke. Not necessarily limited to anybody that would respond when you yell "what does 42 mean?" from your cubicle. The Linux peeps made an effort to #define ENOMSG to 42, for example. Don't use void main(), show your code, name you compiler and OS to get ahead. – Hans Passant Sep 18 '19 at 22:38
  • 1
    So you're making a program and it is closing on itself, and you ask us why without providing any code whatsoever. How are we supposed to help you? – Havenard Sep 18 '19 at 23:06
  • [relevant](https://stackoverflow.com/q/39366400/10957435). –  Sep 18 '19 at 23:13
  • Possible duplicate of [Why is it exit(42)?](https://stackoverflow.com/questions/39366400/why-is-it-exit42) –  Sep 18 '19 at 23:14
  • Hang on. You said you're "doing a program with matrix". Are you saying that you're getting this status from a program that you wrote? If so, and if you want help, you *must* show us a [mre] (read that link) and tell us what environment you're using (operating system, compiler, IDE if any). I can imagine that some C++ implementation would cause your program to do an implicit `exit(42)` in some circumstances, but we can't tell without more information. (And now I'm curious.) – Keith Thompson Sep 19 '19 at 01:14

2 Answers2

5

It means that the program executed exit(42), or return 42; from within the main function, or some equivalent. It has no universal meaning.

On UNIX-like systems conventionally 0 means success and 1 means failure. Other return values may have meanings, but they're specific to each program (there might be some more general conventions, but they're not universal).

I sometimes use exit(42) as a placeholder. 42 is a common "arbitrary" integer value, just as foo is a common arbitrary identifier, because 42 is the Answer to the Ultimate Question of Life, the Universe, and Everything.

Keith Thompson
  • 254,901
  • 44
  • 429
  • 631
0

This is a custom return code from the pacman implementation, and you should look up the spec of the implementation to figure out what error does 42 indicate.