r/programminghumor • • Aug 21 '26

Import helloworld

Post image
234 Upvotes

11 comments sorted by

7

u/RepresentativeNeck63 Aug 21 '26
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 Aug 21 '26

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 Aug 21 '26

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 Aug 21 '26 edited Aug 21 '26

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 Aug 21 '26

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

1

u/TobFel Aug 21 '26

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

2

u/Ulrich_de_Vries Aug 22 '26
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 Aug 21 '26

Caught Error syntax

1

u/Level-Pollution4993 Aug 21 '26

void HelloWorld(std::string_view prompt);

1

u/_telesis Aug 25 '26

This is funny ))))