Skip to main content
0 votes
3 answers
299 views

In C, if we want to evaluate multiple statements as one, we can use the comma. This evaluates both args in order, then returns the value of the second. However, what if I want to evaluate two ...
Coarse Rosinflower's user avatar
1 vote
3 answers
118 views

#include <stdio.h> #define PRINT(x) (printf("%d\n", x), x) int main() { int a = 1; switch (a) { case PRINT(1): puts("Case 1"); break; case PRINT(2)...
Alphin Thomas's user avatar
27 votes
3 answers
5k views

Some time ago I stumbled upon the idea of how a C construct, such as (expr0, expr1, expr2), evaluates (see "What does the comma operator , do?" for more context). I've started experimenting ...
sleeptightAnsiC's user avatar
2 votes
4 answers
135 views

I was given the code: #include <stdio.h> int main(void) { int a = 0, b = 0, c = 0; c = (a -= a - 5), (a = b, b + 3); printf("a = %d, b = %d, c = %d", a, b, c); // a = 0, b =...
xiushama's user avatar
3 votes
2 answers
258 views

My program was crashing, no debugger readily available, so I spiked it with printfs, narrowed it down to the (lengthy) initializer list, and tried to get it to show which initializer expression causes ...
SF.'s user avatar
  • 14.1k
2 votes
1 answer
109 views

x={f(){return this}} x.f() //x (x.f)() //x (0,x.f)() //window I've learned that parenthesis (grouping operator) does not apply GetValue to the expression inside it, while other operators such as , ...
Cutie Florent's user avatar
0 votes
1 answer
60 views

const test = ( (success) => { console.log('SUCCESS CALLED'); }, (error) => { console.log('ERROR CALLED'); } ); test(); // output is **ERROR CALLED** In ...
Jaf's user avatar
  • 961
1 vote
3 answers
85 views

Is there a way to execute some code as a precursor to initializing class members? Take the following code as an example: void enableCreationOfAObjects(); class AObject { public: AObject(int i, ...
Kishore Jonnalagadda's user avatar
0 votes
2 answers
91 views

Why does this code compile ? int X = (2,4); I compiled this line with c++ replit the second value (4) is assigned to X
Chanoch's user avatar
  • 45
2 votes
4 answers
178 views

Having some significant confusion about what it means to "evaluate in list context", specifically related to the comma operator. In the linked perlop doc, it says: In list context, it's just ...
fmg's user avatar
  • 945
1 vote
2 answers
122 views

Following snippet is from mac sdk signal.h: #define sigemptyset(set) (*(set) = 0, 0) just wonder what does , 0) do?
mzoz's user avatar
  • 1,393
0 votes
3 answers
359 views

So here's that piece of code, very basic but i just can't find any similar questions that have two variables in the while loop with cin in it. void Perm(int start, int end, int a[]) { //some ...
Awakoto's user avatar
  • 13
1 vote
1 answer
122 views

while experimenting with the answer from This post, ended up with the following piece of code: #include <iostream> #include <typeinfo> namespace Test { struct MyPtr { ...
J.M's user avatar
  • 337
3 votes
3 answers
110 views

#include<stdio.h> void main() { int g = 83; int h = (g++, ++g); printf(“%d”, h); } **g++** will increment **g** after **;** My answer: h = 84 Correct answer: h = 85 I am a ...
Tushar K. Sengar's user avatar
2 votes
1 answer
62 views

Why does this code not throw a compilation error for y being undeclared? int x = 10, y; printf("%d", y); There's no expression like int y;. In my case, the console print out is 32764, ...
calexandra1's user avatar

15 30 50 per page
1
2 3 4 5
19