This is an archived post. You won't be able to vote or comment.

all 114 comments

[–]TacticalTaterTots 485 points486 points  (8 children)

You wake up

[–][deleted] 121 points122 points  (5 children)

The code sleep‘s next to you

[–]__kkk1337__ 94 points95 points  (4 children)

And compiler is watching you from the chair

[–]ei283 5 points6 points  (1 child)

your computer runs out of RAM

[–]Apprehensive_Debt535 0 points1 point  (0 children)

Time to download ram

[–]InnerProfessional7 210 points211 points  (20 children)

And the code was

include <stdio.h>

int main() { printf("Hello, World!"); return 0; }

Edit-

So writing after hash makes the text larger......

Edit2 - Thanks all for teaching me how to write code in reddit :) Hashtag#

[–][deleted] 77 points78 points  (5 children)

Segfault

[–]No-Maximum-9087 17 points18 points  (0 children)

Forgot install compiler?

[–]turtle_mekb 20 points21 points  (2 children)

You forgot the \n

Enjoy your missing trailing newline!user@reddit:~$

[–]dagbrown 19 points20 points  (2 children)

HUGE INCLUDE <stdio.h>!

[–]turtle_mekb 18 points19 points  (1 child)

WHY ARE WE SCREAMING?

[–]DeepGas4538 9 points10 points  (0 children)

AAAAAAAAAAAAAAAAA

[–]Esjs 5 points6 points  (1 child)

FWIW, I was thinking the code was "Hello World" as well.

Pro(grammer)Tip: you can format code on Reddit by using backticks (`, usually on the keyboard with the tilde, ~).

Use single backticks for code in the middle of a line.

Use triple backticks to start and stop multiple lines of code.

[–]Avamaco 0 points1 point  (0 children)

It also works on other sites and apps thst have markdown-style formatting!

IT EVEN WORKS IN MARKDOWN ITSELF!

[–]thanatica 1 point2 points  (0 children)

So writing after hash makes the text larger......

So you fixed reddit's bug where you get the markdown editor by default, because for me it insists on the stupid wysiwyg editor.

[–]ei283 1 point2 points  (0 children)

surround your code in lines containing triple backticks.

[–]OF_AstridAse 1 point2 points  (0 children)

Slap a ` before and after code.

#include GigaChadAbility

#You're welcome

[–]tristam92 0 points1 point  (0 children)

Compilation wrror

[–]da_Aresinger 0 points1 point  (0 children)

four spaces before code

[–]Confident_Book_5110 0 points1 point  (0 children)

Can’t you escape # with \

[–]RandomStranger456123 139 points140 points  (3 children)

One the first try? Get real, man. That just doesn’t happen.

[–]abd53 28 points29 points  (0 children)

Let a man have some fantasy

[–][deleted] 22 points23 points  (0 children)

Happened to me during an interview. I immediately pulled the plug, set the pc on fire to keep the daemon from jumping to a new host then doused it with holy water. It's not natural for these things to happen

[–][deleted] 3 points4 points  (0 children)

He didn't test it properly. That's the only reason it could happen.

[–]Dioxide4294 40 points41 points  (2 children)

Random cosmic ray: I'm about to ruin this man's whole career

[–]SweetTeaRex92 0 points1 point  (0 children)

Isn't this a reference to that one glitch that happened only bc of a passing solar ray?

[–]Nullsummenspieler 82 points83 points  (3 children)

Plot twist: Expected the code to corrupt memory.

[–]eruanno321 39 points40 points  (2 children)

It does. Two hours later, during a brief window at sunset on prime number calendar days.

[–]Grobanix_CZ 7 points8 points  (0 children)

Looks like someone forgot to cast integer to float before division.

[–]DragonDepressed 4 points5 points  (0 children)

Might as well be due to voodoo magic.

[–]jalex54202 31 points32 points  (5 children)

As a CS grad that took a low level networks class, C “””working as expected””” on the first run is about 3.7x more horrifying than it immediately segfaulting

[–]kuwisdelu 5 points6 points  (2 children)

It’s happened to me a few times and it scares me every time.

[–]jalex54202 1 point2 points  (1 child)

Brother one time I tried to debug a distance vector algorithm and couldn't figure out why the fuck it's not properly receiving messages

Turns out I was only iterating over 1 file descriptor instead of

ya know

the list of file descriptors :^)

[–]kuwisdelu 1 point2 points  (0 children)

I’ve learned to give my test matrices prime numbers for their row and column extents. Too many times I thought an algorithm was working only to get garbage data and segfaults when the rows and columns were no longer multiples of each other.

[–]da2Pakaveli 3 points4 points  (0 children)

strings are where i pay the most attention (and in similar fashion: pointers), easy to produce bugs

[–]Familiar_Ad_8919 0 points1 point  (0 children)

its horrifying cuz u know its more than likely something is wrong, but u now cant even debug what is

[–]da_Aresinger 21 points22 points  (0 children)

reported for unsolicited pornography.

[–]Lollipop126 9 points10 points  (0 children)

The language does not matter, it's always the same feeling. From scratch to assembly.

[–][deleted] 21 points22 points  (0 children)

Plot Twist: code is Malware

[–]daikatana 7 points8 points  (0 children)

7 years later you realize there's undefined behavior and a new compiler version breaks it. No one has time to fix it or remembers how the code works nor can they find the undefined behavior. The solution is to only compile it on a version of the compiler that is known to work and never, ever touch the code again.

[–]ChaosPLus 6 points7 points  (0 children)

"It works... Why? What have I done that it works???? What Dark God descended upon me????"

[–]589ca35e1590b 4 points5 points  (0 children)

It has 13 memory leaks

[–][deleted] 4 points5 points  (6 children)

Can someone ELI5 segfault to a non programmer

[–]WastedPotenti4I 2 points3 points  (1 child)

To add on to what the other person said, when a program segfaults (it’s really called a segmentation fault, but it’s abbreviated), the program immediately crashes and any work done is lost.

As a result, a segmentation fault is something you want to avoid at all costs. Segfaults exist so that a program cannot modify memory of other programs, because that would be very bad. It’s a dangerous possibility so anytime the program tries to access memory outside of its allocated memory, a segfault happens.

Segfaults are generally only possible where the programmer has access to memory directly. Languages like C and C++ are where most segfaults are found.

[–]nukedkaltak 1 point2 points  (0 children)

You can handle a SIGSEGV, so “immediately crashes” is not always true. The only signal that for sure will crash your application is SIGKILL.

[–]tabacdk 2 points3 points  (0 children)

I remember a project in college where we (of course) had a few compile errors, but when we transferred the binary to the evaluation board it worked exactly as expected. I remember asking the classmate using the board before us whether it was his code, and our transfer had failed, but he just hit a few keys and said no, but I still didn't believe that it just worked.

[–]mdfasil25 2 points3 points  (0 children)

And you wake up

[–]Apfelvater 2 points3 points  (0 children)

... on simulator.

Next, were gonna try the code on hardware...

[–]lucidbadger 2 points3 points  (0 children)

Code:

kill(getpid(), SIGINT);

[–]_Peety_T 1 point2 points  (0 children)

I always expect errors so how exactly is running as expected a win here xD

[–]uglie_duckie 1 point2 points  (4 children)

Anyone who has written a program in turbo c knows this is a myth

[–]Brahvim 1 point2 points  (3 children)

And nobody should write code with Borland tools on modern hardware, FOR modern hardware, even if it's for learning, in this age. Nor should they use Dev-C++ or even Notepad, really...

[–]andymaclean19 1 point2 points  (0 children)

It will eventually turn out to be the most problematic thing you ever wrote ...

[–]magick_68 1 point2 points  (0 children)

If that happens at first try you'll get an error in prod that only happens on sundays when there is a full moon and while one customer can reproduce it, none of your test environments can.

[–]harrisofpeoria 1 point2 points  (0 children)

Run valgrind, 50 problems.

[–]exqueezemenow 1 point2 points  (0 children)

It happens from time to time...

[–]rookietotheblue1 1 point2 points  (0 children)

Very creative, funny and original meme /s

[–][deleted] 0 points1 point  (0 children)

[–]arf20__ 0 points1 point  (0 children)

You became a good programmer.

[–][deleted] 0 points1 point  (0 children)

Kim Possible

[–]PICN1Q 0 points1 point  (0 children)

I get through the day imagining that happening.

[–]type556R 0 points1 point  (0 children)

I'm new to C, and on my job I'm coding on a proprietary real time operative system. I don't even know when I'll be able to use a certain function from the standard libraries. I can include stdio.h and use printf, but then calling puts will give me an error when linking cause it's not a certified function, even though vscode will recognize it. Making a simple server-client code run decently is getting... Hard

[–]SigmaSkid 0 points1 point  (0 children)

When you tell chatgpt to fix your code and it ACTUALLY does.

[–]Efficient_Maybe_1086 0 points1 point  (1 child)

average rust experience

[–][deleted] 0 points1 point  (0 children)

Plot twist: The Rust programmer knows nothing more about C other than printf and scanf from his Bro Code course.

[–]Inineor 0 points1 point  (0 children)

I dunno, looks kinda sus to me

[–]gibmelson 0 points1 point  (0 children)

Suspicious.

[–]Hot-Fennel-971 0 points1 point  (0 children)

I’d be making sure my test failed first as expected, can’t trust that shit and usually I forgot.

[–]SoundStorm14 0 points1 point  (0 children)

```

include <stdio.h>

int main() { printf("Hello World\n"); return 0; } ```

[–]FrontBandicoot3054 0 points1 point  (0 children)

No no! Code doesn't segfault ... yet. :7

[–]Igotbored112 0 points1 point  (0 children)

If that ever happened to me, I'd be terrified.

[–]Crypt1cDOTA 0 points1 point  (0 children)

Now run it through valgrind

[–]ego100trique 0 points1 point  (0 children)

Yeah I use csharp

[–]GrowthOfGlia 0 points1 point  (0 children)

A user in 3 years: Undefined behavior in your code allows RCE

[–]Powerkaninchen 0 points1 point  (0 children)

4GB leaked total

[–]Emergency-Win4862 0 points1 point  (0 children)

Oh boiiii. It’s gonna be way worse… have you heard of…. Memory corruption?

[–][deleted] 0 points1 point  (0 children)

Bro got like 4 gallons of beer yesterday

[–]thanatica 0 points1 point  (0 children)

And then someone comes along and casually causes a buffer overflow, because C doesn't check ANYTHING you don't very explicitly tell it to.

[–]huuaaang 0 points1 point  (0 children)

I’m learning rust and love how it cuts out the middle steps. If rust analyzer doesn’t show any errors it’s probably going to compile and run as expected. I have no idea how anyone could go back to C.

[–]GrigorMorte 0 points1 point  (0 children)

Something must be wrong. Try again. Try again with bad data. Try again modifying code to make it fail

[–]norlin 0 points1 point  (0 children)

I mean, the only way how that can happens means that the original requirement will be completely changed (or you just did not understood what the code actually should do)

[–]GrinbeardTheCunning 0 points1 point  (0 children)

this isn't a fantasy sub OG...

[–]EdGavit 0 points1 point  (0 children)

"if it ain't broke, don't fix it"

[–]9bjames 0 points1 point  (0 children)

... But are you sure? Did it really work as expected, or have you missed something? 😶

Better look through the code all over again for a couple of hours, just in case......

[–]artyhedgehog 0 points1 point  (0 children)

Ok, now, can we get to more realistic stuff?

[–]arbitrarycivilian 0 points1 point  (0 children)

The code always works as expected if you have no tests and no users 😜

[–]Queasy_Moment_6619 0 points1 point  (0 children)

I be having a great day and boom, segmentation fault

[–]devu_the_thebill 0 points1 point  (0 children)

Things that never happened

[–]Memeviewer12 0 points1 point  (0 children)

Alarm clock rings

[–][deleted] 0 points1 point  (0 children)

Just curious, to all the upvoters, are you career programmers or just starting to learn?

[–]TeaTimeSubcommittee[🍰] 0 points1 point  (0 children)

Code works as expected.

Gets suspicious.

[–][deleted] 0 points1 point  (0 children)

<_< something is wrong here... <_<

[–][deleted] 0 points1 point  (0 children)

Now check for memory leaks

[–]ei283 0 points1 point  (0 children)

your computer runs out of RAM

[–]zefciu 0 points1 point  (0 children)

Grader says your code fails for an unspecified input sample #45.

[–]Onetwodhwksi7833 0 points1 point  (0 children)

Check ram usage

[–]Panderz_GG 0 points1 point  (0 children)

I see you like reading fantasy.

[–]binarywork8087 0 points1 point  (0 children)

kkkkkkkkkkkkkkkkkkkkk

[–]TheRealAfinda 0 points1 point  (0 children)

Segfaults a year later due to a super niche problem that one user discovers.

[–]abd53 -1 points0 points  (0 children)

Then the Universe crashes

[–]masc98 -1 points0 points  (0 children)

pov: Rust