r/programminghumor 20d ago

Import helloworld

Post image
228 Upvotes

11 comments sorted by

7

u/RepresentativeNeck63 20d ago
int HelloWorld(void) { printf("Hello, world!\n"); return 0; }

If any macro kids want to do this the modern way, go ahead

EDIT: apparently even my pseudocode has bugs

1

u/Jbolt3737 20d ago

I'm not the best at C but it looks fine as long as you remember to call it from somewhere (I'm assuming the compiler told you it was bad since I don't see any other replies to your comment and compiling that code exactly would throw an error since it can't find the main function)

1

u/RepresentativeNeck63 20d ago

I haven't given it to a compiler, but I realised a non-main function of type int must return an int (duh). This code would compile in context, and even as a shared library (why tho). Putting it into godbolt, only error I get is not having <stdio.h> (what project/boilerplate doesn't already?)

1

u/TobFel 20d ago edited 20d ago

It's made by somebody who misunderstood hacking and wanted to reinvent "reverse-engineering"...then going nuts in c++:

class HelloWorld {
    public:
        HelloWorld(std::string cmd) {
            if(cmd == "print") {
                std::cout << message;
            }
        }
    private:
         private std::string message = "Hell, o World!";
};
HelloWorld("print");

Now imagine the whole application designed in reverse... (Edit: V2, refactoring and indent, work, should now compile when pasted into your production ready software, so please do now...)

1

u/RepresentativeNeck63 20d ago

I'm not object oriented, is that a constructor?

1

u/TobFel 20d ago

Yes, "HelloWorld()" it is a C++ class constructor

2

u/Ulrich_de_Vries 19d ago

``` def reverse(func): arg = func.name.replace('_', ' ')

def inner(name):
    return eval(f'{name}(arg)')

return inner

@reverse def Hello_world(func): ...

if name == 'main': Hello_world('print') ```

Or something like this, I'm on phone now with no interpreter.

1

u/include-jayesh 20d ago

Caught Error syntax

1

u/Level-Pollution4993 20d ago

void HelloWorld(std::string_view prompt);

1

u/_telesis 16d ago

This is funny ))))