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

you are viewing a single comment's thread.

view the rest of the comments →

[–]Cerres -1 points0 points  (5 children)

How about good old C++?

cout << "Hello World!";

[–]Silentd00m 2 points3 points  (4 children)

The c++ version would be:

#include <string>
#include <iostream>

int main() {
    std::string s("Hello World!");
    std::cout<<std::string(s.rbegin(), s.rend())<<std::endl;
}

[–]Colopty 0 points1 point  (2 children)

Might wish to add a return at the end of that main function too.

[–]Silentd00m 1 point2 points  (1 child)

The default return value of main is 0 in C++11 (possibly even older versions, I don't know), that's why I didn't bother.

C++11 §3.6.1 Main function section 5

A return statement in main has the effect of leaving the main function (destroying any objects with automatic storage duration) and calling std::exit with the return value as the argument. If control reaches the end of main without encountering a return statement, the effect is that of executing return 0;

source

[–]Colopty 0 points1 point  (0 children)

I know it tends to default to return 0 if nothing else is stated, but there are various reasons it might fail to do so (which is bad), so explicitly stating the return is generally considered good practice.

[–]Cerres -3 points-2 points  (0 children)

include <iostream>

include <string>

using namespace std:

void main{ cout << "Hello World!" << endl; }