[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]

Let's write a program in c++ /b/ I'll start: int main() {

The stories and information posted here are artistic works of fiction and falsehood.
Only a fool would take anything posted here as fact.

Thread replies: 119
Thread images: 5

File: C-PNG-Clipart.png (5KB, 550x380px) Image search: [Google]
C-PNG-Clipart.png
5KB, 550x380px
Let's write a program in c++ /b/

I'll start:

int main()
{
>>
return 0;
}
>>
return 0;
}
>>
Delete system32
>>
>>723821587
nailed it
>>
>>723821587
>>723821616
plebs, return 0; is not even neccessary.
>>
>>723821587
>>723821616

I love you guys
>>
while(true) printf("OP is a faggot\n");
>>
>>723821684
In that case, shouldn't the main method be void ?
>>
>>723821728
That just hurts
>>
cout<<"fuck you nigger "<<endl;
>>
Hell: printf("Fuckit");
Goto Hell;

return 0;
}
>>
extern int library_call() {
printf("hello world\n");
>>
cout << "Shoud I kill myself?";
cin >> lifePoints ;
>>
Now one on Python
>>
>>723821922
cout << "Shoud I kill myself?";
cin >> lifePoints ;

if (lifePoints < 1)
{
suicide = true;
}
>>
//Reminding /b/ users of their obsolete language
alert('Why are you not using .js? Get with the time grandpa!');
>>
Goto "Tag1";
>>
>>723821587
fpbp
>>
perl -e 'print "op is a faggot\n"'
>>
>>723821705
faggot
>>
>>723821966

import brackets
>>
>>723821966
>>723821922
>>723821877
>>723821799
>>723821666
Boy, meme magic is strong in this thread
>>
>>723821783
Compilers (at least the most common ones) atuomatically insert the return 0; but yeah, void main would also do the trick
>>
using namespace std;
>>
>>723821966
return 0
>>
>>723822091
Nothing you guys write will matter untill you write "tag1" and cancel this faggot's goto
>>
>>723821728
just use for(;;) and skip the while(true)
>>
// Should we write this in pseudo code first?
>>
>>723821966
while op is faggot:
println('OP is a faggot')
>>
>>723821512
no headers

goodlck
>>
insert javascript
>>
>>723822266
This is C++ not C
>>
#include <iostream>
>>
int main()
{
std::string name;
std::cout << "What is your name? ";
getline (std::cin, name);
std::cout << "Hello, " << name << "!\n";
}
>>
>>723822266
Is there a practical difference between the two? If not I prefer while(true) for readability's sake
>>
>>723822605
println... Python. Clearly a java programmer that doesn't know Python
>>
>>723822702
That depends on the compiler. Theoretically they could be optimized to be the same thing.
>>
>>723822749
you caught me... I've been working on a java project the past few weeks and I'm still new to python. I'm probably a stupid asshole too ;)
>>
>>723822691
using namespace std;

don't waste your time putting in std:: everywhere
>>
>>723822888
Check 'em
>>
>>723822126
>>>/pol/
Nobody cares
>>
File: 1484501807906.jpg (14KB, 298x312px) Image search: [Google]
1484501807906.jpg
14KB, 298x312px
Well done boys. How about we contribute to a brandnew piece of software and actually help humamity to progress instead?
>>
>>723822888
I know but its like a habit of mine
>>
File: IMG_1969.jpg (34KB, 298x444px) Image search: [Google]
IMG_1969.jpg
34KB, 298x444px
/*
>>
>>723821728
That would cause an infinite loop
>>
>>723822888
However you should put your using declaration inside of the main function in case you cause a name collision in the future.
>>
>>723822749
def println( out ):
print( out + '\n' )
return
>>
>>723823140
I think that's the point.
>>
>>723823259
and that's why significant whitespace sucks balls
>>
>>723823259
This is still a naive aproach. Print already does a newline and also you don't have to return. You could simply:

println = print
>>
container.AddFacility<WcfFacility>().Register
(
Component.For<IGay4chan>()
.AsWcfClient(new DefaultClientModel
{
Endpoint = WcfEndpoint.BoundTo(new BasicHttpBinding()).At("http://localhost/IGay4chan.WebService/IGay4chan.svc")
}),
Component.For<IFurryGuy>()
.AsWcfClient(new DefaultClientModel
{
Endpoint = WcfEndpoint.BoundTo(new BasicHttpBinding()).At("http://localhost/IFurryGuy.WebService/IFurryGuy.svc")
})
);
>>
>>723822691
int main()
{
string name;
cout << "What is your name? ";
getline (cin, name);
cout << "Hello, " << name << "!\n";
if (name == "uvuvueuvue")
{
cout << "Pardon" << endl;
}
}
>>
01001111 01010000 00100000 01101001 01110011 00100000 01100001 00100000 01100110 01100001 01100111 01100111 01101111 01110100

Lol i feel so smart.
>>
>>723823049
>>723823259
>>723823423
*/
>>
>>723823042
you honestly think these faggots can anything more than hello world?
>>
>>723823506
I was naive, i admit
>>
>>723823453
01100111 01100110 01111001 01110011 00100000 00111011 00101001
>>
#include <iostream.h>
#include <string.h>

using namespace std;

int main (){
char postNumber[9];
cin>>postNumber;
if (postNumber[8]==postNumber[7])
cout<<"Check'em!";
return (0);
}
>>
>>723823408
out = 'rim me'
def thatsthejoke ( out ):
i = 0
while i < len( out ):
print out[i] + ' '
i += 1
>>
>>723822656
both work in C and C++
>>
>>723821684
Wouldn't the missing return 0 cause a compiler warning which if the program is being compiled to treat warnings as errors would make the return 0 necessary?
>>
>>723823654
^^

Also:
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
string string1;
string string2;
int rot;

while (true)
{
string2 = "";

cout << "Enter string: ";
cin >> string1;
cout << "Enter ROT value: ";
cin >> rot;

char c[30];

for (int i = 0; i < string1.length(); i++)
{
if (string1.at(i) + rot > 90)
{
c[i] = string1.at(i) + rot - 26;
}
else if (string1.at(i) + rot < 65)
{
c[i] = string1.at(i) + rot + 26;
}
else
{
c[i] = string1.at(i) + rot;
}

string2 += c[i];
}

cout << string2 << endl;
}
}
>>
>>723822605
>println
>python
get out
>>
>>723823793
But they both have different styles and best-practices.
>>
>>723822656
then argue the other guy for using printf and not cout

>>723822702
as for speed and size I have no clue which one is actually better I just prefer using "dumb" for-loops when it's things that should just be spammed.
>>
#include <iostream>
using namespace std;
void main()
{
int num1, num2;
unsigned long long fact = 1;
cout << "Please Enter Number: ";
cin >> num1;
for(num2=num1; num2>=1; num2--)
fact*=num2;
cout << fact << "\n\n\n\n";
system("pause");
}
>>
>>723821877
Grosss a goto when a while loop is an option. What is this? a .bat
>>
>>723823049
>>723823472

You gotta be a faggot
>>
if (No. == 723825555)
{
post == true;
}
>>
>>723824592
you'd have to query the javascript quote, otherwise you're using an undefined variable
>>
>>post == true;

Error: unexpected "==" in expression, coder must be a faggot
>>
>>723821684
if you explicitly define a return value of int, you better fucking return something xD
>>
//Try this fun program to get a laugh

#include <unistd.h>

int main(void)
{
while(1){ fork(); }
return 0;
}
>>
worked 5 minutes on this perl:

perl -MMIME::Base64 -e "do{print decode_base64(((split(qq(=)=>qq('=please_execute _me=b3AgaXMgYSBmYWc=ebYYSBmWcf=BYSBmmYcr=DgtYeYSBmc=')))[@ARGV]).qq(=)).qq( ===== )} foreach (@1000 .. 1000)" 2
>>
>>723823800
Just tried it using GCC 4.9.2:
int main() { } is working flawlessly (even if checking for standard main conformity).

void main() { } produces an error (main not standard conform)

g++ -Wextra -pdeantic -w -Wfatal-errors -Wmain main.cpp
>>
>>723821512
puts you're a cock
>>
>>723825425
>inb4 deletes sys32
>>
>>723825608
na just creates a load of processes
>>
>>723825608
It's a fork bomb faggot.
>>
>>723821512
int numberOfReasonsToLive()
{
return 0;
}
>>
>>723825452

perl -MMIME::Base64 -e "do{print decode_base64(((split(qq(=)=>qq(''=please_execute _me=b3AgaXMgYSBmYWc=ebYYSBmWcf=BYSBmmYcr=DgtYeYSBmc='''''''')))[@ARGV]).qq(=)).qq( = ) x 10} foreach (@1000 .. 1000)" 2
>>
File: 1402009449547.jpg (59KB, 625x494px) Image search: [Google]
1402009449547.jpg
59KB, 625x494px
>>723825808
i like this
>>
>>723823140
Aren't you special.
>>
>>723821783
>>723822145

Void main is not standard c++, and you shouldn't use it. Some compilers will allow it but most won't
>>
>>723822702
You can do
#define EVER ;;
And have for(EVER)
>>
>>723821512
;INITIALIZING
on *:connect:{
join #Tori
rlevel 1000
rlevel 500
rlevel 250
rlevel 100
}

;BAN CHECKER
on gb:JOIN:#:{ mode $chan +b $nick | kick $chan $nick Globale ban }
on cb:JOIN:#:{
if ($chan isin $ulist($address($nick,5),cb,1).info) {
mode $chan +b $nick
kick $chan $nick Geband op dit kanaal
}
}

;OPPING/VOICING
on *:JOIN:#:{
if ($nick != $me) {
if ($readini(channels.ini,$chan,auto-voice) == on) { mode $chan +v $nick }
if ($readini(channels.ini,$chan,auto-op) == on) { mode $chan +o $nick }
if (*o* iswm $readini(channels.ini,$chan,$nick)) { mode $chan +o $nick }
elseif (*v* iswm $readini(channels.ini,$chan,$nick)) { mode $chan +v $nick }
if ($readini(channels.ini,$chan,chan_greet)) { notice $nick $readini(channels.ini,$chan,chan_greet) }
if ($readini(channels.ini,$chan,count) == on) {
if ($readini(channels.ini,tellers,$chan) != $null) {
writeini channels.ini tellers $chan [ $calc($readini(channels.ini,tellers,$chan) + 1) ]
}
else { writeini channels.ini tellers $chan 1 }
msg $chan 10 $+ $nick welkom Je bent persoon nr.4 $readini(channels.ini,tellers,$chan) 10die $chan komt bezoeken het is nu01 [4 $asctime(HH:nn) 01]
}
}
if ($readini(channels.ini,$chan,chan_limit)) { timer_limit 1 5 mode $chan +l $calc($nick($chan,0,a) + $readini(channels.ini,$chan,chan_limit)) }
if ($readini(channels.ini,$chan,peak) == on) {
_peak.check $chan
}
}
>>
>>723825460
I tried it in VS2015 and it didn't produce any warnings for int main() { } either so I guess it's fine. I saw the following is part of the C++ standard:

A return statement in main has the effect of leaving the main function (destroying any objects with automatic storage duration) and calling 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;

This behavior seems to ONLY work for the main method, because if you make another method:

int test() { }

Then that method gives you an error about how it must return a value.
>>
>>723825372
that's for the kernel to worry about, program will compile and execute just fine
>>
>>723826595
Yay. Finally I was correct at something.

So int main() { } is completely valid.

What surprised me though is, that for main to be conform you don't have to use main(int argc, char *argv[])
>>
__asm hlt
>>
>>723826339
I like the way you think
>>
switch (registerSet[Registers::RepetitionMode].value)
{
case RepetitionModes::NotZero: {
do {
instructionSet[opcode]->execute(destination, source, registerSet, ram, operand1DataSize);
registerSet[Registers::CX].value -= 1;
} while (registerSet[Registers::CX].value == 0);

registerSet[Registers::RepetitionMode].value = RepetitionModes::Off;
break;
}
case RepetitionModes::Zero: {
do {
instructionSet[opcode]->execute(destination, source, registerSet, ram, operand1DataSize);
registerSet[Registers::CX].value -= 1;
} while (registerSet[Registers::CX].value != 0);

registerSet[Registers::RepetitionMode].value = RepetitionModes::Off;
}
break;
case RepetitionModes::Off: {
instructionSet[opcode]->execute(destination, source, registerSet, ram, operand1DataSize);
break;
}
}
>>
// IMPORTANT: Adafruit_TFTLCD LIBRARY MUST BE SPECIFICALLY
// CONFIGURED FOR EITHER THE TFT SHIELD OR THE BREAKOUT BOARD.
// SEE RELEVANT COMMENTS IN Adafruit_TFTLCD.h FOR SETUP.

// Modified for SPFD5408 Library by Joao Lopes
// and touch instead serial !!!!
// Too much modifications, so not: begins e ends
// Version 0.9.2 - Rotation for Mega and screen initial

#include <SPFD5408_Adafruit_GFX.h> // Core graphics library
#include <SPFD5408_Adafruit_TFTLCD.h> // Hardware-specific library
#include <SPFD5408_TouchScreen.h> // Touch library

// The control pins for the LCD can be assigned to any digital or
// analog pins...but we'll use the analog pins as this allows us to
// double up the pins with the touch screen (see the TFT paint example).
#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0

#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin

// When using the BREAKOUT BOARD only, use these 8 data lines to the LCD:
// For the Arduino Uno, Duemilanove, Diecimila, etc.:
// D0 connects to digital pin 8 (Notice these are
// D1 connects to digital pin 9 NOT in order!)
// D2 connects to digital pin 2
// D3 connects to digital pin 3
// D4 connects to digital pin 4
// D5 connects to digital pin 5
// D6 connects to digital pin 6
// D7 connects to digital pin 7
// For the Arduino Mega, use digital pins 22 through 29
// (on the 2-row header at the end of the board).

// Assign human-readable names to some common 16-bit color values:
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
>>
#include <iostream>

#define HAND int main()
#define NIGGASCREAMS std::cout<<
#define STOPIT <<std::endl;
#define JUSTDOIT while
#define FOREVER true

HAND{
JUSTDOIT(FOREVER)
NIGGASCREAMS "So hacky" STOPIT
}
>>
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
// If using the shield, all control and data lines are fixed, and
// a simpler declaration can optionally be used:
// Adafruit_TFTLCD tft;
>>
cd code
cd..
cd..
cd..
cd..
ls
cd code
cd..
>>
>>723827842
Oh god, I tried to forget about THAT thing...
>>
>>723821512
int main() {
int age = 0, chics = 0;
cout << "put ur age and chiks u ve fuked this year" << endl;
cin >> age >> chics;
if (age > 17 and chics == 0) cout << "u an fgt" << endl;
else cout << "u re on 4chan so u an fgt anyway" << endl;
return 0;
}
>>
>>723826339
forever implies it will never end though, while a loop such as that is obviously not meant to go forever in any real world application. A loop like that would typically terminate on a break or a return.
>>
def op(faggot):
n = [f,a,g,g,o,t]
for i in n:
print i
>>
#define if while
>>
>>723826700
then write void main()
>>
#define true false
>>
fuck you pseudo intelligents meateaters (: fuck you
>>
@echo off
>>
for i in xrange(10):
print "fag"
>>
>>723828630
>>723828873

stop dis
>>
File: 1443977265942.jpg (48KB, 533x462px) Image search: [Google]
1443977265942.jpg
48KB, 533x462px
>>723828579
No fucking infinite loop goes on forever you fucking moron. It merely indicates that the loop will not terminate on its own for not having a break condition or one that is never met. But you already knew that, so stop being a smartass.
>>
#include <iostream.h>
using namespace std;

int main (){
While(True){
cout<<"OP is a FAGGOT";
}
return (0);
}
>>
>>723822266
listen to
>>723822656
Readability above all else
>>
:(){ :|: & };:
>>
>>723821512

isostream.jew
>>
Print "What is your name?\n";
my $input = <STDIN>;
chomp($input);
print "Hello, $input\n";
>>
for(int i = 0; i < 1000000; i ++)
{
std::count<<"go fuck yourself";
}
>>
#include <iostream>
#include <stdlib.h>
using namespace std;

int main()
{
cout << "OP" << endl;
cout << "IS" << endl;
cout << "A" << endl;
cout << "FAGGOT" << endl;
cout << "press ENTER to quit" << endl;
std::string trash;
std::getline(std::cin, trash);

return 0;
}
>>
PERL > C++
>>
>>723830498
>PERL > C++
An expression that returns false
>>
>>723821512
any advice to learn. books do they work
Thread posts: 119
Thread images: 5


[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.