What does a comma mean inside an 'if' statement? [duplicate]What does the comma operator , do?comma operator in if conditionWhat is the difference between #include <filename> and #include “filename”?What are the differences between a pointer variable and a reference variable in C++?What does the explicit keyword mean?What is the “-->” operator in C++?What is The Rule of Three?What is the meaning of prepended double colon “::”?What are the basic rules and idioms for operator overloading?C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Why are elementwise additions much faster in separate loops than in a combined loop?Why is my program slow when looping over exactly 8192 elements?

I know that there is a preselected candidate for a position to be filled at my department. What should I do?

Which European Languages are not Indo-European?

My players want to grind XP but we're using milestone advancement

Can a US state pass/enforce a law stating that a group of people owe money to the state government?

My employer faked my resume to acquire projects

Are black holes spherical during merger?

Where have Brexit voters gone?

Construct a word ladder

Should one buy new hardware after a system compromise?

Apt - strange requests to d16r8ew072anqo.cloudfront.net:80

Defining the standard model of PA so that a space alien could understand

What could a self-sustaining lunar colony slowly lose that would ultimately prove fatal?

Who decides how to classify a novel?

Is it rude to call a professor by their last name with no prefix in a non-academic setting?

Can I connect my older mathematica front-end to the free wolfram engine?

Is the Indo-European language family made up?

Why most published works in medical imaging try reducing false positives?

Why didn't Thanos use the Time Stone to stop the Avengers' plan?

Where's this lookout in Nova Scotia?

Find the three digit Prime number P from the given unusual relationships

How can I tell if I'm being too picky as a referee?

Python program to take in two strings and print the larger string

Why would Ryanair allow me to book this journey through a third party, but not through their own website?

Popcorn is the only acceptable snack to consume while watching a movie



What does a comma mean inside an 'if' statement? [duplicate]


What does the comma operator , do?comma operator in if conditionWhat is the difference between #include <filename> and #include “filename”?What are the differences between a pointer variable and a reference variable in C++?What does the explicit keyword mean?What is the “-->” operator in C++?What is The Rule of Three?What is the meaning of prepended double colon “::”?What are the basic rules and idioms for operator overloading?C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Why are elementwise additions much faster in separate loops than in a combined loop?Why is my program slow when looping over exactly 8192 elements?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








22
















This question already has an answer here:



  • What does the comma operator , do?

    9 answers



Consider:



for (auto i = 0; i < g.size(); ++i)
for (auto j = 0; j < g.size(); ++j) if (g[i][j] == 0) dfs(g, i, j), ++regions;
return regions;


I don't like one line code. What does the code execute in the if()?



I am confused by the "," sign.



Usually I would write it as:



 for (auto i = 0; i < g.size(); ++i)

for (auto j = 0; j < g.size(); ++j)

if (g[i][j] == 0)

dfs(g, i, j)

,++regions; // I am not sure what to do here. Inside the "if" scope??


return regions;









share|improve this question















marked as duplicate by phuclv, David Z, Community May 12 at 4:11


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.













  • 1





    The second code snippet is not balanced - there are three opening s and two closing s - it is missing a }.

    – Peter Mortensen
    May 11 at 22:53












  • See also here: stackoverflow.com/questions/16475032/…

    – Valentino
    May 11 at 23:07

















22
















This question already has an answer here:



  • What does the comma operator , do?

    9 answers



Consider:



for (auto i = 0; i < g.size(); ++i)
for (auto j = 0; j < g.size(); ++j) if (g[i][j] == 0) dfs(g, i, j), ++regions;
return regions;


I don't like one line code. What does the code execute in the if()?



I am confused by the "," sign.



Usually I would write it as:



 for (auto i = 0; i < g.size(); ++i)

for (auto j = 0; j < g.size(); ++j)

if (g[i][j] == 0)

dfs(g, i, j)

,++regions; // I am not sure what to do here. Inside the "if" scope??


return regions;









share|improve this question















marked as duplicate by phuclv, David Z, Community May 12 at 4:11


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.













  • 1





    The second code snippet is not balanced - there are three opening s and two closing s - it is missing a }.

    – Peter Mortensen
    May 11 at 22:53












  • See also here: stackoverflow.com/questions/16475032/…

    – Valentino
    May 11 at 23:07













22












22








22









This question already has an answer here:



  • What does the comma operator , do?

    9 answers



Consider:



for (auto i = 0; i < g.size(); ++i)
for (auto j = 0; j < g.size(); ++j) if (g[i][j] == 0) dfs(g, i, j), ++regions;
return regions;


I don't like one line code. What does the code execute in the if()?



I am confused by the "," sign.



Usually I would write it as:



 for (auto i = 0; i < g.size(); ++i)

for (auto j = 0; j < g.size(); ++j)

if (g[i][j] == 0)

dfs(g, i, j)

,++regions; // I am not sure what to do here. Inside the "if" scope??


return regions;









share|improve this question

















This question already has an answer here:



  • What does the comma operator , do?

    9 answers



Consider:



for (auto i = 0; i < g.size(); ++i)
for (auto j = 0; j < g.size(); ++j) if (g[i][j] == 0) dfs(g, i, j), ++regions;
return regions;


I don't like one line code. What does the code execute in the if()?



I am confused by the "," sign.



Usually I would write it as:



 for (auto i = 0; i < g.size(); ++i)

for (auto j = 0; j < g.size(); ++j)

if (g[i][j] == 0)

dfs(g, i, j)

,++regions; // I am not sure what to do here. Inside the "if" scope??


return regions;




This question already has an answer here:



  • What does the comma operator , do?

    9 answers







c++






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 14 at 17:13







Gilad

















asked May 11 at 20:44









GiladGilad

3,53383992




3,53383992




marked as duplicate by phuclv, David Z, Community May 12 at 4:11


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by phuclv, David Z, Community May 12 at 4:11


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









  • 1





    The second code snippet is not balanced - there are three opening s and two closing s - it is missing a }.

    – Peter Mortensen
    May 11 at 22:53












  • See also here: stackoverflow.com/questions/16475032/…

    – Valentino
    May 11 at 23:07












  • 1





    The second code snippet is not balanced - there are three opening s and two closing s - it is missing a }.

    – Peter Mortensen
    May 11 at 22:53












  • See also here: stackoverflow.com/questions/16475032/…

    – Valentino
    May 11 at 23:07







1




1





The second code snippet is not balanced - there are three opening s and two closing s - it is missing a }.

– Peter Mortensen
May 11 at 22:53






The second code snippet is not balanced - there are three opening s and two closing s - it is missing a }.

– Peter Mortensen
May 11 at 22:53














See also here: stackoverflow.com/questions/16475032/…

– Valentino
May 11 at 23:07





See also here: stackoverflow.com/questions/16475032/…

– Valentino
May 11 at 23:07












1 Answer
1






active

oldest

votes


















28














The programmer has used the comma operator to provide two unrelated expressions in a single statement. Because it's a single statement, both expressions are "inside" the if condition.



It's a poor hack, which would be better done with actual braces surrounding two statements.



Your example is not equivalent; it should be:



if (g[i][j] == 0) 

dfs(g, i, j);
++regions;






share|improve this answer


















  • 7





    ohh god, why why why would anyone write this code. Thanks

    – Gilad
    May 11 at 20:50






  • 8





    @Gilad Trying to be clever, most likely! And failing.

    – Lightness Races in Orbit
    May 11 at 20:51






  • 4





    @LightnessRacesinOrbit This is a habit of old school programmers due to small monitor resolution (25 rows 80 columns) code was writing as short as possible. More code on one page better readability. Try read modern code on such monitor and you will see how many empty rows in it.

    – Andrey Sv
    May 11 at 21:14






  • 3





    Of course, that hack is especially useful for macros, which one also should avoid assiduously.

    – Deduplicator
    May 11 at 21:33






  • 3





    @AndreySv Such programmers have had some thirty years to break that habit, i.e. since before C++ even existed.

    – Lightness Races in Orbit
    May 11 at 22:59

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









28














The programmer has used the comma operator to provide two unrelated expressions in a single statement. Because it's a single statement, both expressions are "inside" the if condition.



It's a poor hack, which would be better done with actual braces surrounding two statements.



Your example is not equivalent; it should be:



if (g[i][j] == 0) 

dfs(g, i, j);
++regions;






share|improve this answer


















  • 7





    ohh god, why why why would anyone write this code. Thanks

    – Gilad
    May 11 at 20:50






  • 8





    @Gilad Trying to be clever, most likely! And failing.

    – Lightness Races in Orbit
    May 11 at 20:51






  • 4





    @LightnessRacesinOrbit This is a habit of old school programmers due to small monitor resolution (25 rows 80 columns) code was writing as short as possible. More code on one page better readability. Try read modern code on such monitor and you will see how many empty rows in it.

    – Andrey Sv
    May 11 at 21:14






  • 3





    Of course, that hack is especially useful for macros, which one also should avoid assiduously.

    – Deduplicator
    May 11 at 21:33






  • 3





    @AndreySv Such programmers have had some thirty years to break that habit, i.e. since before C++ even existed.

    – Lightness Races in Orbit
    May 11 at 22:59















28














The programmer has used the comma operator to provide two unrelated expressions in a single statement. Because it's a single statement, both expressions are "inside" the if condition.



It's a poor hack, which would be better done with actual braces surrounding two statements.



Your example is not equivalent; it should be:



if (g[i][j] == 0) 

dfs(g, i, j);
++regions;






share|improve this answer


















  • 7





    ohh god, why why why would anyone write this code. Thanks

    – Gilad
    May 11 at 20:50






  • 8





    @Gilad Trying to be clever, most likely! And failing.

    – Lightness Races in Orbit
    May 11 at 20:51






  • 4





    @LightnessRacesinOrbit This is a habit of old school programmers due to small monitor resolution (25 rows 80 columns) code was writing as short as possible. More code on one page better readability. Try read modern code on such monitor and you will see how many empty rows in it.

    – Andrey Sv
    May 11 at 21:14






  • 3





    Of course, that hack is especially useful for macros, which one also should avoid assiduously.

    – Deduplicator
    May 11 at 21:33






  • 3





    @AndreySv Such programmers have had some thirty years to break that habit, i.e. since before C++ even existed.

    – Lightness Races in Orbit
    May 11 at 22:59













28












28








28







The programmer has used the comma operator to provide two unrelated expressions in a single statement. Because it's a single statement, both expressions are "inside" the if condition.



It's a poor hack, which would be better done with actual braces surrounding two statements.



Your example is not equivalent; it should be:



if (g[i][j] == 0) 

dfs(g, i, j);
++regions;






share|improve this answer













The programmer has used the comma operator to provide two unrelated expressions in a single statement. Because it's a single statement, both expressions are "inside" the if condition.



It's a poor hack, which would be better done with actual braces surrounding two statements.



Your example is not equivalent; it should be:



if (g[i][j] == 0) 

dfs(g, i, j);
++regions;







share|improve this answer












share|improve this answer



share|improve this answer










answered May 11 at 20:46









Lightness Races in OrbitLightness Races in Orbit

300k56485833




300k56485833







  • 7





    ohh god, why why why would anyone write this code. Thanks

    – Gilad
    May 11 at 20:50






  • 8





    @Gilad Trying to be clever, most likely! And failing.

    – Lightness Races in Orbit
    May 11 at 20:51






  • 4





    @LightnessRacesinOrbit This is a habit of old school programmers due to small monitor resolution (25 rows 80 columns) code was writing as short as possible. More code on one page better readability. Try read modern code on such monitor and you will see how many empty rows in it.

    – Andrey Sv
    May 11 at 21:14






  • 3





    Of course, that hack is especially useful for macros, which one also should avoid assiduously.

    – Deduplicator
    May 11 at 21:33






  • 3





    @AndreySv Such programmers have had some thirty years to break that habit, i.e. since before C++ even existed.

    – Lightness Races in Orbit
    May 11 at 22:59












  • 7





    ohh god, why why why would anyone write this code. Thanks

    – Gilad
    May 11 at 20:50






  • 8





    @Gilad Trying to be clever, most likely! And failing.

    – Lightness Races in Orbit
    May 11 at 20:51






  • 4





    @LightnessRacesinOrbit This is a habit of old school programmers due to small monitor resolution (25 rows 80 columns) code was writing as short as possible. More code on one page better readability. Try read modern code on such monitor and you will see how many empty rows in it.

    – Andrey Sv
    May 11 at 21:14






  • 3





    Of course, that hack is especially useful for macros, which one also should avoid assiduously.

    – Deduplicator
    May 11 at 21:33






  • 3





    @AndreySv Such programmers have had some thirty years to break that habit, i.e. since before C++ even existed.

    – Lightness Races in Orbit
    May 11 at 22:59







7




7





ohh god, why why why would anyone write this code. Thanks

– Gilad
May 11 at 20:50





ohh god, why why why would anyone write this code. Thanks

– Gilad
May 11 at 20:50




8




8





@Gilad Trying to be clever, most likely! And failing.

– Lightness Races in Orbit
May 11 at 20:51





@Gilad Trying to be clever, most likely! And failing.

– Lightness Races in Orbit
May 11 at 20:51




4




4





@LightnessRacesinOrbit This is a habit of old school programmers due to small monitor resolution (25 rows 80 columns) code was writing as short as possible. More code on one page better readability. Try read modern code on such monitor and you will see how many empty rows in it.

– Andrey Sv
May 11 at 21:14





@LightnessRacesinOrbit This is a habit of old school programmers due to small monitor resolution (25 rows 80 columns) code was writing as short as possible. More code on one page better readability. Try read modern code on such monitor and you will see how many empty rows in it.

– Andrey Sv
May 11 at 21:14




3




3





Of course, that hack is especially useful for macros, which one also should avoid assiduously.

– Deduplicator
May 11 at 21:33





Of course, that hack is especially useful for macros, which one also should avoid assiduously.

– Deduplicator
May 11 at 21:33




3




3





@AndreySv Such programmers have had some thirty years to break that habit, i.e. since before C++ even existed.

– Lightness Races in Orbit
May 11 at 22:59





@AndreySv Such programmers have had some thirty years to break that habit, i.e. since before C++ even existed.

– Lightness Races in Orbit
May 11 at 22:59





Popular posts from this blog

Club Baloncesto Breogán Índice Historia | Pavillón | Nome | O Breogán na cultura popular | Xogadores | Adestradores | Presidentes | Palmarés | Historial | Líderes | Notas | Véxase tamén | Menú de navegacióncbbreogan.galCadroGuía oficial da ACB 2009-10, páxina 201Guía oficial ACB 1992, páxina 183. Editorial DB.É de 6.500 espectadores sentados axeitándose á última normativa"Estudiantes Junior, entre as mellores canteiras"o orixinalHemeroteca El Mundo Deportivo, 16 setembro de 1970, páxina 12Historia do BreogánAlfredo Pérez, o último canoneiroHistoria C.B. BreogánHemeroteca de El Mundo DeportivoJimmy Wright, norteamericano do Breogán deixará Lugo por ameazas de morteResultados de Breogán en 1986-87Resultados de Breogán en 1990-91Ficha de Velimir Perasović en acb.comResultados de Breogán en 1994-95Breogán arrasa al Barça. "El Mundo Deportivo", 27 de setembro de 1999, páxina 58CB Breogán - FC BarcelonaA FEB invita a participar nunha nova Liga EuropeaCharlie Bell na prensa estatalMáximos anotadores 2005Tempada 2005-06 : Tódolos Xogadores da Xornada""Non quero pensar nunha man negra, mais pregúntome que está a pasar""o orixinalRaúl López, orgulloso dos xogadores, presume da boa saúde económica do BreogánJulio González confirma que cesa como presidente del BreogánHomenaxe a Lisardo GómezA tempada do rexurdimento celesteEntrevista a Lisardo GómezEl COB dinamita el Pazo para forzar el quinto (69-73)Cafés Candelas, patrocinador del CB Breogán"Suso Lázare, novo presidente do Breogán"o orixinalCafés Candelas Breogán firma el mayor triunfo de la historiaEl Breogán realizará 17 homenajes por su cincuenta aniversario"O Breogán honra ao seu fundador e primeiro presidente"o orixinalMiguel Giao recibiu a homenaxe do PazoHomenaxe aos primeiros gladiadores celestesO home que nos amosa como ver o Breo co corazónTita Franco será homenaxeada polos #50anosdeBreoJulio Vila recibirá unha homenaxe in memoriam polos #50anosdeBreo"O Breogán homenaxeará aos seus aboados máis veteráns"Pechada ovación a «Capi» Sanmartín e Ricardo «Corazón de González»Homenaxe por décadas de informaciónPaco García volve ao Pazo con motivo do 50 aniversario"Resultados y clasificaciones""O Cafés Candelas Breogán, campión da Copa Princesa""O Cafés Candelas Breogán, equipo ACB"C.B. Breogán"Proxecto social"o orixinal"Centros asociados"o orixinalFicha en imdb.comMario Camus trata la recuperación del amor en 'La vieja música', su última película"Páxina web oficial""Club Baloncesto Breogán""C. B. Breogán S.A.D."eehttp://www.fegaba.com

Vilaño, A Laracha Índice Patrimonio | Lugares e parroquias | Véxase tamén | Menú de navegación43°14′52″N 8°36′03″O / 43.24775, -8.60070

Cegueira Índice Epidemioloxía | Deficiencia visual | Tipos de cegueira | Principais causas de cegueira | Tratamento | Técnicas de adaptación e axudas | Vida dos cegos | Primeiros auxilios | Crenzas respecto das persoas cegas | Crenzas das persoas cegas | O neno deficiente visual | Aspectos psicolóxicos da cegueira | Notas | Véxase tamén | Menú de navegación54.054.154.436928256blindnessDicionario da Real Academia GalegaPortal das Palabras"International Standards: Visual Standards — Aspects and Ranges of Vision Loss with Emphasis on Population Surveys.""Visual impairment and blindness""Presentan un plan para previr a cegueira"o orixinalACCDV Associació Catalana de Cecs i Disminuïts Visuals - PMFTrachoma"Effect of gene therapy on visual function in Leber's congenital amaurosis"1844137110.1056/NEJMoa0802268Cans guía - os mellores amigos dos cegosArquivadoEscola de cans guía para cegos en Mortágua, PortugalArquivado"Tecnología para ciegos y deficientes visuales. Recopilación de recursos gratuitos en la Red""Colorino""‘COL.diesis’, escuchar los sonidos del color""COL.diesis: Transforming Colour into Melody and Implementing the Result in a Colour Sensor Device"o orixinal"Sistema de desarrollo de sinestesia color-sonido para invidentes utilizando un protocolo de audio""Enseñanza táctil - geometría y color. Juegos didácticos para niños ciegos y videntes""Sistema Constanz"L'ocupació laboral dels cecs a l'Estat espanyol està pràcticament equiparada a la de les persones amb visió, entrevista amb Pedro ZuritaONCE (Organización Nacional de Cegos de España)Prevención da cegueiraDescrición de deficiencias visuais (Disc@pnet)Braillín, un boneco atractivo para calquera neno, con ou sen discapacidade, que permite familiarizarse co sistema de escritura e lectura brailleAxudas Técnicas36838ID00897494007150-90057129528256DOID:1432HP:0000618D001766C10.597.751.941.162C97109C0155020