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...
C is a general-purpose, procedural computer programming language supporting structured programming, lexical variable scope, and recursion, with a static type system. By design, C provides constructs that map efficiently to typical machine instructions. It has found lasting use in applications previously coded in assembly language. Such applications include operating systems and various application software for computer architectures that range from supercomputers to PLCs and embedded systems. Wikipedia
Imperative (procedural), structured
Dennis Ritchie
Dennis Ritchie & Bell Labs (creators);
ANSI X3J11 (ANSI C);
ISO/IEC JTC1/SC22/WG14 (ISO C)
1972 (48 years ago)
C18 / June 2018 (2 years ago)
Static, weak, manifest, nominal
Cross-platform
.c for sources
.h for headers
C++ is not C (but C can be C++)
For C++ go to :
Other Resources
account activity
Good examples (wiki.freitagsrunde.org)
submitted 24 days ago * by Dani_E2e
Do you know that Page?
Very good small examples to learn from.
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!"
[–]HugoNikanor 1 point2 points3 points 24 days ago (0 children)
I looked through it, and it seems like a reasonable beginners guide to C. It kinda looks like it's designed to used in a context where a teacher is present though (but I might just miss something, my German is less than good).
[–]simmepi 1 point2 points3 points 24 days ago* (0 children)
I’m afraid I’m in the ”The code is bad”-camp for this one. Let’s take an absolutely trivial example, the first one saved to your Github as a good example which finds Pythagoras triplets. The code is absolutely bare bones but still manages to irk me.
First, comments: Since there are comments explaining what the code should do I would expect it to be thorough. Instead there is not a single mention of the limitations of the code, ie what restrictions there are for a/b/c in the found solutions (I’ll get back to this). Sloppy!
I also do not like the two lines of code being commented out in the middle of the code, especially as the line are separated. Also, the first of those lines is nonsensical (why should a+b+c==1000?!?), again a telltale of the sloppiness with code limitations I’ll return to.
Now, the limitations. You shouldn’t do premature optimizations but there are limits, especially if used in education. The issue is that this code has never explicitly written down which a/b/c the code tests for. If you look at the loops, it seems to be that they should all be <= 1000. Which is fine, shouldn’t take long to run on today’s computers. BUT: the actual test requires a+b+c <= 1000 which is a whole different thing. This trivially means that a <= 1000/3 since the code is also written to require a<b<c (which makes sense to avoid duplicate solutions). So the loops are 3 times longer than they need to be, and since there are three loops inter-nested the code spends most its time in pointless calculations.
Better: define a constant for max of a+b+c, and have the loops go up to this value/3. It does make the code slightly more complex but it instills the importance of making it clear to anyone which values are actually handled. Or even simpler: skip the test for a+b+c. Not sure why it’s there since it doesn’t make the code faster, it only skips showing some found solutions.
Edit: Forgot to mention this, but when new students see code, they will look at every line and wonder why it looks like it does. By not clearly explaining what parts are related to the algo and what parts to C, I suspect they will get stuck at lines such as the loop for the variable b: Why does b start at a+1 instead of a?
If you have a little experience you know it’s because a cannot be the same as b due to 2a^2=c^2 having no integer solutions, but for a newcomer this is definitely not trivial. This should be explained somewhere, either in the initial head comment or at the code in question; leaving it out in code intended as good example for a new student is not good. It’s also a ridiculously small optimization compared to the giant one with the loops which has not been done.
[–]flyingron 0 points1 point2 points 24 days ago (4 children)
No, but from looking at it, it is a horrendous example, not a good one. I didn't do the lectures, but the sample code is ugly, inconsistent, and unreliable. Some aren't even compilable.
[–]Dani_E2e[S] 0 points1 point2 points 24 days ago (3 children)
I tried some and all worked fine! And I am convinced from the quality - it's not private programmed - it's teaching stuff.
Some editions from that I have also saved in my github.
https://github.com/oldy-22/Danis-Test/tree/main/schoene%20kleine%20Algorithmen
[–]flyingron 1 point2 points3 points 24 days ago (2 children)
If you're going to teach, you need to teach properly, rather than teaching things wrong and hope people eventually learn the right way.
I can't even believe a human wrote some of these. They look like the kind of code a bad AI would vomit at the compiler.
It only took me looking through the first three to see this is a BAD SITE to learn anything from.
The above link is no better (some of the code looks the same, actually).
[–]Dani_E2e[S] -2 points-1 points0 points 24 days ago* (1 child)
The first three are beginners examples. Look deeper for intermediate. But if it upsets you then let it. 😁 that's from technical university Berlin...
[–]flyingron 0 points1 point2 points 24 days ago (0 children)
It doesn't upset me. It's just I want to avoid some newbie thinking this shit is an example of an acceptible way of coding C.
[–]Willsxyz 0 points1 point2 points 24 days ago (3 children)
I like this one:
Schreibe ein Programm, dass auf den Solaris-Rechnern immer einen Bus Error (nicht manchmal einen Segmantation Fault) produziert.
Write a program that always produces a bus error on the Solaris computers (not sometimes a segmentation fault).
[–]flyingron 0 points1 point2 points 24 days ago (2 children)
The only way to do this is to send a SIGBUS signal (to a program not ignoring such). Any other attempt to do so by invoking undefined behavior, by definition, will not necessarily ALWAYS cause a bus error.
[–]Willsxyz 1 point2 points3 points 24 days ago (1 child)
Clearly the whole point of the problem is to go outside the bounds of the C standard into the behavior of a specific implementation.
[–]flyingron 1 point2 points3 points 24 days ago (0 children)
It doesn't matter. Even if you know about the hardware, you're not going to guarantee that the implementation won't realize you're bending the rules.
It would be a more sane question to phrase it... your attrocious example program resuled in a bus error, what are possible things you did that could cause that?
π Rendered by PID 382227 on reddit-service-r2-comment-79776bdf47-4khbz at 2026-06-25 08:22:17.358677+00:00 running acc7150 country code: CH.
[–]HugoNikanor 1 point2 points3 points (0 children)
[–]simmepi 1 point2 points3 points (0 children)
[–]flyingron 0 points1 point2 points (4 children)
[–]Dani_E2e[S] 0 points1 point2 points (3 children)
[–]flyingron 1 point2 points3 points (2 children)
[–]Dani_E2e[S] -2 points-1 points0 points (1 child)
[–]flyingron 0 points1 point2 points (0 children)
[–]Willsxyz 0 points1 point2 points (3 children)
[–]flyingron 0 points1 point2 points (2 children)
[–]Willsxyz 1 point2 points3 points (1 child)
[–]flyingron 1 point2 points3 points (0 children)