5
I'm looking for some solution in returning values in main function, I need to shorten my program more, return 0
takes too much characters of my code, I need to return 0, or my code fails. I know that in C there can be no return
statement, and then program will use result of last operation - but on which operations I can 'really' shorten my code?
At the moment I found brk(0)
as shortest return.
main(n){while(~scanf("%i",&n))printf("%i ",n*~n/-2);brk(0);}
2Which code-golfing contest requires that
main
return 0? – feersum – 2015-02-01T09:49:50.587It would help to know some things: Can
n
be 0? Does extra whitespace invalidate the answer? – feersum – 2015-02-01T10:06:09.4231@feersum it's from spoj challenges, code has to pass test - it has to return 0 or it does not pass it because of error, n can be <1,1001>, it can print answers with spaces, or new lines, it does not matter, judge checks numbers, i can even write 100x ' ' between each result – encoree1337 – 2015-02-01T11:55:52.057
1
@encoree1337 "in C there can be no return statement, and then program will use result of last operation" - I think you are pushing it a bit there. Can you point to that being specified anywhere? As opposed to the result of last operation just coincidentally being left in the accumulator, which is where the return value would be on x86 (but not necessarily on other architectures)? http://en.wikipedia.org/wiki/X86_calling_conventions
– Mawg says reinstate Monica – 2015-03-11T12:40:59.917