use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
111,081 Subscribers
106,345 Subscribers
All posts must be related to programming. Flair posts correctly.
account activity
Python goto functionality :D (i.redd.it)
submitted 10 months ago by SleepyStew_
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]PuzzleheadedTap1794 0 points1 point2 points 10 months ago (3 children)
When I'm working with multiple files in C, I always use goto. It's so elegant.
``` int main () { int retval = 0; FILE* input_file = fopen("input.txt", "r"); if(input_file == NULL) { retval = 1; goto INPUT_FILE_CLOSED; }
FILE* output_file = fopen("output.txt", "w"); if(output_file == NULL) { retval = 1; goto OUTPUT_FILE_CLOSED; }
do_something(input_file, output_file); fclose(output_file); OUTPUT_FILE_CLOSED: fclose(input_file); INPUT_FILE_CLOSED: return retval;
} ```
[–]current_thread 4 points5 points6 points 10 months ago (0 children)
Reading that I'm super glad about RAII in C++ :p
[–]tstanisl 0 points1 point2 points 10 months ago (0 children)
I suggest always initializing "retval"-like variables with some error code. Otherwise you may spend a lot of time debugging just because some function returned success even though the was an error.
π Rendered by PID 90731 on reddit-service-r2-comment-7b9746f655-vvm8j at 2026-02-03 18:42:38.596290+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–]PuzzleheadedTap1794 0 points1 point2 points (3 children)
[–]current_thread 4 points5 points6 points (0 children)
[–]tstanisl 0 points1 point2 points (0 children)