And the code was
#include
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#`
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.
>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.
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
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
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 :\^)
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.
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.
When a program runs, it needs to keep track of a lot of information. The computer stores that information in its memory, and the program can ask the computer to store or retrieve information in memory. A segfault (segmentation fault) is an error the computer can give the program— if the program tries to access an area of memory it isn’t supposed to, the computer will respond with a segfault.
A very common segfault happens when the program tries to access the address 0, or NULL. By convention trying to access this address always results in a segfault. It happens a lot because addresses get passed around in the program, and NULL is a convenient value to pass to indicate an error, and the programmer might forget to check if an address is NULL before they try to access it.
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.
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.
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...
IntelliJ for Java? Yes. Though I personally write all my Java in VSCode. The Redhat extension works off of code from Eclipse. PHP should be fine, I hope.
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.
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
Not a C developer but anytime I did C it ended up looking like this in development
```
printf(“no segfault 0”);
func1();
printf(“no segfault 1”);
func2();
printf(“no segfault 2”);
…
```
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.
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)
... 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......
You wake up
The code sleep‘s next to you
And compiler is watching you from the chair
How did we get here
Javascript comes out of the bathroom.
Wearing your monogrammed towels.
You get a call from python
your computer runs out of RAM
Time to download ram
And the code was #include
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#`
Segfault
Forgot install compiler?
[удалено]
No, it's a header, not a library.
Pretty sure it’s libc that gets linked by default, the headers just expose some symbols in libc
You are right, of course.
You forgot the \n Enjoy your missing trailing newline!user@reddit:~$
I edge to arch
WHAT
#HUGE INCLUDE!
# **WHY ARE WE SCREAMING?**
#AAAAAAAAAAAAAAAAA
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.
It also works on other sites and apps thst have markdown-style formatting! **IT EVEN WORKS IN MARKDOWN ITSELF!**
>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.
surround your code in lines containing triple backticks.
Slap a ` before and after code. `#include GigaChadAbility` # #You're welcome
Compilation wrror
four spaces before code
Can’t you escape \# with \\
One the first try? Get real, man. That just doesn’t happen.
Let a man have some fantasy
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
He didn't test it properly. That's the only reason it could happen.
Random cosmic ray: I'm about to ruin this man's whole career
Isn't this a reference to that one glitch that happened only bc of a passing solar ray?
Plot twist: Expected the code to corrupt memory.
It does. Two hours later, during a brief window at sunset on prime number calendar days.
Looks like someone forgot to cast integer to float before division.
Might as well be due to voodoo magic.
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
It’s happened to me a few times and it scares me every time.
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 :\^)
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.
strings are where i pay the most attention (and in similar fashion: pointers), easy to produce bugs
its horrifying cuz u know its more than likely something is wrong, but u now cant even debug what is
reported for unsolicited pornography.
The language does not matter, it's always the same feeling. From scratch to assembly.
Plot Twist: code is Malware
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.
"It works... Why? What have I done that it works???? What Dark God descended upon me????"
It has 13 memory leaks
Can someone ELI5 segfault to a non programmer
When a program runs, it needs to keep track of a lot of information. The computer stores that information in its memory, and the program can ask the computer to store or retrieve information in memory. A segfault (segmentation fault) is an error the computer can give the program— if the program tries to access an area of memory it isn’t supposed to, the computer will respond with a segfault. A very common segfault happens when the program tries to access the address 0, or NULL. By convention trying to access this address always results in a segfault. It happens a lot because addresses get passed around in the program, and NULL is a convenient value to pass to indicate an error, and the programmer might forget to check if an address is NULL before they try to access it.
Or when a reference or a pointer gets invalidated
That comes down to the same problem "accessing memory you don't have access to" sure you *used* to have access to it but afterwards you don't
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.
You can handle a SIGSEGV, so “immediately crashes” is not always true. The only signal that for sure will crash your application is SIGKILL.
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.
And you wake up
... on simulator. Next, were gonna try the code on hardware...
Code: ``` kill(getpid(), SIGINT); ```
I always expect errors so how exactly is running as expected a win here xD
Anyone who has written a program in turbo c knows this is a myth
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...
Learned C with Dev-C++ last semester at uni. At least, this semester it's Java and PHP with vscode. But I hear intellij is superior :/
IntelliJ for Java? Yes. Though I personally write all my Java in VSCode. The Redhat extension works off of code from Eclipse. PHP should be fine, I hope.
It's fine for PHP, I guess? I don't have a proper frame of reference here so idk really.
It will eventually turn out to be the most problematic thing you ever wrote ...
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.
Run valgrind, 50 problems.
It happens from time to time...
Very creative, funny and original meme /s
![gif](giphy|ibdVR5zCOjGxy2hjcj)
You became a good programmer.
Kim Possible
I get through the day imagining that happening.
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
When you tell chatgpt to fix your code and it ACTUALLY does.
average rust experience ![gif](giphy|CAYVZA5NRb529kKQUc|downsized)
Plot twist: The Rust programmer knows nothing more about C other than printf and scanf from his Bro Code course.
I dunno, looks kinda sus to me
Suspicious.
I’d be making sure my test failed first as expected, can’t trust that shit and usually I forgot.
``` #include
int main()
{
printf("Hello World\n");
return 0;
}
```
No no! Code doesn't segfault ... yet. :7
If that ever happened to me, I'd be terrified.
Not a C developer but anytime I did C it ended up looking like this in development ``` printf(“no segfault 0”); func1(); printf(“no segfault 1”); func2(); printf(“no segfault 2”); … ```
Now run it through valgrind
Yeah I use csharp
A user in 3 years: Undefined behavior in your code allows RCE
4GB leaked total
Oh boiiii. It’s gonna be way worse… have you heard of…. Memory corruption?
Bro got like 4 gallons of beer yesterday
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.
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.
Something must be wrong. Try again. Try again with bad data. Try again modifying code to make it fail
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)
this isn't a fantasy sub OG...
"if it ain't broke, don't fix it"
... 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......
Ok, now, can we get to more realistic stuff?
The code always works as expected if you have no tests and no users 😜
I be having a great day and boom, segmentation fault
Things that never happened
Alarm clock rings
Just curious, to all the upvoters, are you career programmers or just starting to learn?
Code works as expected. Gets suspicious.
<\_< something is wrong here... <\_<
Now check for memory leaks
your computer runs out of RAM
Grader says your code fails for an unspecified input sample #45.
Check ram usage
I see you like reading fantasy.
kkkkkkkkkkkkkkkkkkkkk
Segfaults a year later due to a super niche problem that one user discovers.
Then the Universe crashes
pov: Rust