[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

why there's so many versions of c++ Hello World code and

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 13
Thread images: 1

File: 973552.jpg (792KB, 1920x1080px) Image search: [Google]
973552.jpg
792KB, 1920x1080px
why there's so many versions of c++ Hello World code and which one of them is correct?
>>
There aren't that many. Correct are ones that output message similar to "Hello world!" to stdout.
>>
If a piece of code does what it's supposed to do and it compiles, it's correct, you dumb shit.
>>
>>55934136
Uh OP...that's C. And that's not even the standard. As of C89, it is no longer necessary to return an int as the compiler does that implicitly.
>>
>>55934177
How does that make it not standard?
>>
>>55934177
That has nothing to do with the standard, that's simply an implementation detail of the compiler.
>>
The only correct ones are
#include<stdio.h>

int main(void)
{
puts("Hello world!\n");
return 0;
}

and
#include<iostream>

int main(void)
{
using namespace std;
cout << "Hello world!" << endl;
return 0;
}
>>
>>55934224
Why correct using void into main parameter?
>>
>>55934224
>puts and a \n
bruh...
>>
>>55934364
'tism
>>
>>55934136
Some are written in ways to save memory space.
>>
>>55934400
#include <iostream>
#include <vector>

int main()
{
char* s = "hello, world\n";
vector<char> v = new vector<char>(s, s + sizeof(s) / sizeof(char));
for (char *pc = v.begin(); pc < v.end(); pc++)
cout << *pc;
delete v;
}
>>
>>55934577
*std::cout
*s + sizeof(s) / sizeof(char) - 1 (for null termination)
Thread posts: 13
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.