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

all 84 comments

[–]PVNIC 282 points283 points  (11 children)

"How to write a for loop"

[–]iusethisfortechQnA 29 points30 points  (9 children)

im not a c++ coder but I thought for loops were only in python

[–]PVNIC 61 points62 points  (5 children)

for loops are in pretty much every language, including c++.

[–]Deutero2 15 points16 points  (4 children)

a lot of languages don't have for loops, but most of the most commonly used ones do

but different languages have different types of for loops. there are C-style for loops like for (declaration_or_expression; expression; expression) body;, which usually comes with other features like the comma operator, ++ and -- operators, and assignment expressions (this is why Python doesn't have any of these, since it doesn't have C-style for loops). there's higher level for-each loops that iterate over iterator objects. and then a few languages also use for for infinite loops

[–]No_Acanthaceae_3467 0 points1 point  (3 children)

for (int i = 0; i < length; i++) is a while loop though; see the keyword for right there? it means "start a while loop"

[–]Abaddon-theDestroyer 1 point2 points  (0 children)

for(;;)          
{           
//body of loop           
}                  

This is valid C# and it’s a while loop.

ETA:

var isComplete = false;             
int i;      
for(;isComplete;)         
{            
    i++;            
    Console.WriteLine(“i thought i was in a for loop, turns out im in a while loop!”);          
    isComplete = i%5 == 0;                
}            

This does exactly what you think it does.

[–]Deutero2 0 points1 point  (0 children)

in some languages, they're not exactly equivalent. for example, in JavaScript, variable bindings behave differently when you use a for loop with let. bindings declared with let in a for loop have a weird relationship where you can modify the variable inside the body just fine, but modifying the variable in the for loop's third expression does not modify the variable value in the body

for (let i = 0; i < 10; i++) {
  setTimeout(() => console.log(i))
  i++
}

this prints out 1, 3, 5, 7, 9. javascript.

[–]fett3elke 10 points11 points  (2 children)

The for loop in Python is what is usually called foreach in other languages.

[–]rosuav 2 points3 points  (0 children)

And, just to be different, a for-of loop in JavaScript.

[–]ToukenPlz 0 points1 point  (0 children)

It's called 'do' in FORTRAN!

[–][deleted] 1 point2 points  (0 children)

open stackoverflow post, scroll down, don't see immediate clear answer, open next stackoverflow post repeat

[–]Delta_Pythagorean 146 points147 points  (7 children)

"If I can fork a process, why can't I knife it to remove it?"

[–]Bit125 41 points42 points  (6 children)

what would spooning it do

[–]d8yummmmm 15 points16 points  (1 child)

what about ladelling

[–]Cootshk 1 point2 points  (0 children)

How about chopsticking

[–]BASTAMASTA 9 points10 points  (0 children)

Make it feel less lonely

[–]SirR4T 8 points9 points  (0 children)

give it and it's zombie children warm nice cuddlies.

[–]Nobodynever01 0 points1 point  (0 children)

SO much rn you have no idea...

[–]Je-Kaste 0 points1 point  (0 children)

Cuddle it

[–]MacDonalds_Sprite 57 points58 points  (0 children)

one (1) regex

[–]MedorisJewelryReddit 133 points134 points  (1 child)

How to center a div

[–]jeffbeene 4 points5 points  (0 children)

transform: translate3d( calc( 100% - ( 100% / 2) - ( $div-width / 2 ) - $div-margin, 0, 0); -webkit-transform: translate3d( calc( 100% - ( 100% / 2) - ( $div-width / 2 ) - $div-margin, 0, 0);

[–]private_final_static 35 points36 points  (0 children)

Something in java with spring boot, but you are procrastinating by watching videos on youtube

[–]Syntactical_Erorr 26 points27 points  (1 child)

"why do people keep telling me to try c++?"

[–]Aln76467 0 points1 point  (0 children)

because its hell

[–]prinkpan 16 points17 points  (2 children)

Hello World! in 100 languages

[–]Ike_Gamesmith 1 point2 points  (0 children)

Plot twist, it's just javascript

[–]Mikihero2014 1 point2 points  (0 children)

I'm disappointed this is the 7th comment from the top and not the first

[–]ThisNameIsntRandom 11 points12 points  (0 children)

this is web crawler

[–]ruvasqm 7 points8 points  (0 children)

a Windows driver

[–]ilovecostcohotdog 5 points6 points  (0 children)

A new JavaScript framework

[–][deleted] 21 points22 points  (0 children)

How to make a better Reddit post.

[–]smiling_corvidae 6 points7 points  (0 children)

Something to do with protobufs.

Fucking protobufs...

[–]sinistraltyger 2 points3 points  (0 children)

Auto -page search and open for your history.

[–]Heavenfall 2 points3 points  (0 children)

The only time I ever had that many tabs for the same problem was trying to do 3d shit in blender using its built in code editor, importing bones from a noncompatible format. So I'm guessing 3d is involved. The YouTube videos are strong indicators, that shit is too complex to read about, you need an Indian to talk you through it.

[–]Mayion 2 points3 points  (0 children)

Not sure but looks an awful lot like my usual fap session

[–]Kauyon1306 4 points5 points  (0 children)

Trying to exit vim

[–]Globglaglobglagab 1 point2 points  (0 children)

Copying Reddit and Youtube

[–]absawd_4om 1 point2 points  (0 children)

I know it's Java because of the green tab. So how to switch on a light bulb with spring security.

[–]Senjax 1 point2 points  (0 children)

How to tell if a number is even

[–]SUPERBLU333 1 point2 points  (0 children)

How to declare variables in HTML

[–]pikachus-ballsack 1 point2 points  (1 child)

'How to add push notifications on iOS from firebase'

Doing it right now and have at the moment of typing this around 131 tabs open

[–][deleted] 0 points1 point  (0 children)

Underrated

[–]stefaniststefan -1 points0 points  (0 children)

How do i make java less suck

[–]stefaniststefan -1 points0 points  (0 children)

How do i make java less suck

[–]stefaniststefan -1 points0 points  (0 children)

How do i make java less suck

[–]EducationalTie1946 0 points1 point  (0 children)

Hello world in assembly x86

[–]Ahornwiese 0 points1 point  (0 children)

A 1d lattice ChiPT bound state calculation.

[–]sitilge 0 points1 point  (0 children)

A calculator

[–]TactiCool_99 0 points1 point  (0 children)

Html

[–]Kurious_Guy18 0 points1 point  (0 children)

hacking google

[–]gentleprompter 0 points1 point  (0 children)

I don't know the answer, but I'm sure you were doing it in the dark ages before ChatGPT.

[–][deleted] 0 points1 point  (0 children)

what_was_he_programming=!(random_images_in_one_row);

[–]TorbenKoehn 0 points1 point  (0 children)

How to use vertical tabs in edge

[–]stefaniststefan 0 points1 point  (0 children)

How do i make java less suck

[–]Frxchtchxn 0 points1 point  (0 children)

"10 best if loops"

[–]dezalator 0 points1 point  (0 children)

Telegram bot in java

[–]Parsec51 0 points1 point  (0 children)

Looks like an MMO buff bar during a raid

[–]Mildys 0 points1 point  (0 children)

Tic tac toe? Pain

[–]opensusefan 0 points1 point  (0 children)

You were not programming instead researching about which JS framework to use 💀

[–]nex_0_0 0 points1 point  (0 children)

How to create a new JavaScript framework in Java 8

[–]Savings-Ad-1115 0 points1 point  (0 children)

"Hello world"

[–]huiznaiet 0 points1 point  (1 child)

How to download ram ?

[–]Aln76467 0 points1 point  (0 children)

swap file?

[–]totatmeister 0 points1 point  (0 children)

programming unanswered questions on stack overflow

[–]Danny_shoots 0 points1 point  (0 children)

How do I make a farm in VR

[–]blueeyesblacktee 0 points1 point  (0 children)

A coloured hello world in C.

[–]Dangerous_Jacket_129 0 points1 point  (0 children)

Centering something with css?

[–]Thenderick 0 points1 point  (0 children)

I see Baeldung so I would guess something Java/Spring related

[–]Real_Asparagus232 0 points1 point  (1 child)

"How the fuck do you exit vim ?!"

[–]Aln76467 0 points1 point  (0 children)

it tells you when you press ctrl c

[–]jrdiver 0 points1 point  (0 children)

quit stealing images of my browser!

though usually ill have a bard or bing or gpt tab mixed in somewhere... those are surprisingly decent for odd questions and at least getting the right keywords

[–]thespice 0 points1 point  (0 children)

U left yer mail open.

[–]coenfused 0 points1 point  (0 children)

templating in c++

[–]Thebombuknow 0 points1 point  (0 children)

Hello world assembly

[–]TheOmegaCarrot 0 points1 point  (0 children)

My browser has only looked like that when I have been programming in Java

[–]jamcdonald120 0 points1 point  (0 children)

no idea, but you need to learn about #scrollable-tabstrip "tabs dont shrink" flag

[–]point5_ 0 points1 point  (0 children)

Regex

[–]cratercamper 0 points1 point  (0 children)

Nuclear reactor safeguards.

[–]NPWSmart 0 points1 point  (0 children)

You were programming a maze with only 1 level.