So, “Hello, World”—this little phrase is like the secret handshake of our programming community. It feels like we’re all part of a hidden club that recognizes this phrase but never really talks about it. And since no one has claimed to be the current leader of this world, I guess I’ll be its hello, or something like that.
By now, you’ve probably heard, read, or even seen this phrase a million times. All those tutorials start with it to show you how to print something to the screen: “Hello, World,” in our case.
But let’s think about it for a second. Have you ever wondered how long it takes an author to write this famous phrase in their tutorial? We could calculate it as a couple of lines divided by the time it takes to write each line.
Quick Math
Let:
Then, we can express the relationship as follows:
T = N \cdot t
If we want to express the average time taken per line in terms of the total time and the number of lines, we can rearrange the equation:
t = \frac{T}{N}
I am just joking; this was all to test how LaTeX works on my site. I am not that obsessed with “Hello, World.”
So, whether you’ve read it, heard it, or even tried to eat it (not recommended!), “Hello, World” is still a big deal in our journey through the programming world.
This might or might not (hopefully not) be your first encounter with C, but no worries—we will see it together, and it’s easy!
#include <stdio.h>
int main(void) {
("%s\n", (char *)&(long long int){0x6E6576616D6E6973}); return 0;
printf}
// output: sinmaven
Looks hard? Pretty much it is at first glance, but it’s pretty cool to look at it and try to figure it out. For example:
#include <stdio.h>
is used to include the
standard input/output header file.
printf
is the function that we call to print our
formatted text to the standard output.
"%s\n"
is a format specifier:%s
tells the function that we want to print the data
given to it as a string.\n
is just a newline character, meaning that after we
print the string, we want to move our cursor one line after it, or
simply press enter.return 0
means that the function main
has
ended its execution and is returning a value to our device, indicating
how it ran:
You might be wondering why I skipped the
(char *)&(long long int){0x6E6576616D6E6973}
part.
Well, it’s up to you to try to figure out what it is, because this is
not just a tutorial for you to read, but to encourage your research
along with me. I won’t be spoon-feeding you, at least not for free.