Hi,

The way to check if a binary finished successfully is simply to check if
the exit code is 0. Notice that for C/C++ in particular there is a constant
EXIT_SUCCESS defined as 0, and an EXIT_FAILURE defined to 1. Our system (or
any system, for that matter) has no way to determine *why* your program
ended with a non-zero exit code. If you exit with 1, which is what happens
when you return 1 from main(), you are indicating that you ended in
failure. When you say "runs correctly in my machine" that's just because
you didn't print any error to stderr and you didn't check the exit code.

It's true that interpreting exit codes is due to convention, but 0 being
success is a widespread convention as illustrated by the constants I named
in the previous paragraph, and the fact that both C++ and Java will exit
with non-zero in the face of an uncaught exception:

$ echo "int main() { throw; }" > test.cpp && g++ test.cpp && ./test; echo $?
terminate called without an active exception
Aborted
134

I hope this helps understand "Runtime Error" a little better.

Best,
Pablo

On Sun, Apr 22, 2018 at 6:51 AM Anil M <anil.manch...@gmail.com> wrote:

> Does my post look like I was asking a question?  or Sarcasm lost its
> charm.  In fact I asked a question a week ago with this problem, it was put
> on hold because Round 1 is still in progress.  Thank you for your valuable
> Input!
>
> On Sunday, April 22, 2018 at 3:45:02 AM UTC+5:30, Bartholomew Furrow wrote:
> > Anil,
> >
> >
> > The problem is that you've put a line into your program that says "Stop
> executing and tell the executing process that there was an error." I
> understand that you weren't aware that that's what the line does, but
> that's what "return 1;" in your main() function means. Some possible
> changes you could make:
> >
> >
> > - Delete that line.
> > - Change it to return 0;
> >
> >
> > I understand that it's frustrating to have your code, which looks fine
> on your computer, fail online. My experience so far is that this doesn't
> happen often, so hopefully with this out of the way you'll have more luck!
> >
> >
> > Bartholomew
> >
> >
> > On Sat, Apr 21, 2018 at 3:48 PM Anil M <anil.m...@gmail.com> wrote:
> > Google code jam is testing my coding skills or my common knowledge?
> >
> > On Sunday, April 22, 2018, Anil M <anil.m...@gmail.com> wrote:
> > The program that returns one runs pretty well on my computer, i don’t
> rewrite my  main function every time , I just copy paste, I submit the code
> I get a runtime error, why would I think it is because of returning one?
> I’m wasted so much time thinking something is wrong with my code.  I don’t
> have even have the knowledge of returning one. Does google code jam
> guidelines say that the program shouldn’t return one? It is not requirement
> on my computer.
> >
> > On Sunday, April 22, 2018, Xiongqi ZHANG <zhangx...@gmail.com> wrote:
> > Not meant to be harsh, isn't this a common knowledge that exit code is
> used to determine whether a child process finished w/ or w/o any error?
> >
> >
> >
> >
> https://stackoverflow.com/questions/9426045/difference-between-exit0-and-exit1-in-python
> >
> >
> >
> > --
> >
> > You received this message because you are subscribed to the Google
> Groups "Google Code Jam" group.
> >
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to google-code...@googlegroups.com.
> >
> > To post to this group, send email to googl...@googlegroups.com.
> >
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/082fa56b-8409-4787-ac0e-2edb04729ec6%40googlegroups.com
> .
> >
> > For more options, visit https://groups.google.com/d/optout.
> >
> >
> >
> >
> >
> >
> >
> > --
> >
> > You received this message because you are subscribed to the Google
> Groups "Google Code Jam" group.
> >
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to google-code...@googlegroups.com.
> >
> > To post to this group, send email to googl...@googlegroups.com.
> >
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/CAB-p_fh3YvUz7Bjf7_o7crHDHHymZrahV0GAcgsSAmcr--NT2w%40mail.gmail.com
> .
> >
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to google-code+unsubscr...@googlegroups.com.
> To post to this group, send email to google-code@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/ebbe8142-0899-4171-9cc8-1c334972bd95%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-code+unsubscr...@googlegroups.com.
To post to this group, send email to google-code@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/CANa5jcD4eygiGXziUz1P3cs9inUgKij8YbPMKwtSxs_jsyDRUA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to