post-increment Questions
21
Solved
In C, what is the difference between using ++i and i++, and which should be used in the incrementation block of a for loop?
Firenze asked 24/8, 2008 at 5:19
23
Solved
Is there a difference in ++i and i++ in a for loop? Is it simply a syntax thing?
Bolognese asked 27/1, 2009 at 17:53
6
Solved
I have a C program which does queue operations using an array. In that program, they increment a variable inside array. I can't understand how that works. So, please explain these operations:
arra...
Scream asked 13/12, 2015 at 12:16
14
Solved
I don't understand the concept of postfix and prefix increment or decrement. Can anyone give a better explanation?
Phosgenite asked 15/12, 2010 at 0:36
20
Solved
We have the question is there a performance difference between i++ and ++i in C?
What's the answer for C++?
Aguste asked 24/8, 2008 at 7:14
7
Solved
In JavaScript you can use ++ operator before (pre-increment) or after the variable name (post-increment). What, if any, are the differences between these ways of incrementing a variable?
Roquelaure asked 12/8, 2010 at 16:30
8
Solved
I'm reading bytes from a buffer. But sometimes what I'm reading is a word or longer.
// assume buffer is of type unsigned char *
read_ptr(buffer+(position++))
That's fine but how can I post-inc...
Buskined asked 19/3, 2011 at 6:47
3
Can someone please explain whether i = x[i]++; lead to undefined behavior?
Note: x[i] and i are not both volatile and x[i] does not overlap i.
There is C11, 6.5 Expressions, 2 (emphasis added):
If...
Wesla asked 12/4, 2022 at 13:14
3
Solved
I have a question that is raised from this discussion: C - modify the address of a pointer passed to a function
Let's say I have the following code:
#include <stdio.h>
foo(char **ptr){
*ptr+...
Perfectly asked 16/11, 2021 at 17:42
12
Solved
I'm currently learning C++ and I've learned about the incrementation a while ago.
I know that you can use "++x" to make the incrementation before and "x++" to do it after.
Still, I really don't kn...
Dionysiac asked 28/11, 2009 at 16:45
1
Solved
Code
#include<iostream>
int main()
{
int a=3;
a++=5;
std::cout<<a;
}
Output (as expected)
[Error] lvalue required as left operand of assignment
1. The post increment operator (a++)...
Protector asked 18/7, 2021 at 16:16
8
Solved
Half jokingly half serious : Why can't I do ++i++ in C-like languages, specifically in C#?
I'd expect it to increment the value, use that in my expression, then increment again.
Peppergrass asked 2/10, 2009 at 18:20
11
Solved
From the program below or here, why does the last call to System.out.println(i) print the value 7?
class PrePostDemo {
public static void main(String[] args) {
int i = 3;
i++;
System.out.print...
Pori asked 24/3, 2011 at 1:5
18
Solved
What happens (behind the curtains) when this is executed?
int x = 7;
x = x++;
That is, when a variable is post incremented and assigned to itself in one statement? I compiled and executed this. ...
Obtund asked 27/10, 2011 at 4:39
4
Solved
I know that here are some explanations about the difference between p++, ++p and p+1 but I couldn't understand it clearly yet, especially when it's not working with that function:
void replace(cha...
Snotty asked 10/5, 2020 at 0:10
2
Solved
I tried constructing pairs of integers where the second integer is greater than the first by 1:
1 2
2 3
3 4
Using both std::make_pair and the constructor like so:
std::make_pair(n, n++);
Howe...
Openwork asked 2/5, 2020 at 22:6
1
Solved
Although this question might be answered somewhere and I could not find it.
Below written first statement work whereas second does not? WHY?
int main() {
int x = 1, y = 2;
int *p = &++x; /...
Miltiades asked 8/4, 2020 at 19:21
5
Solved
I have a question, how the compiler operate on the following code:
#include<stdio.h>
int main(void)
{
int b=12, c=11;
int d = (b == c++) ? (c+1) : (c-1);
printf("d = %i\n", d);
}
I am ...
Arbor asked 11/2, 2020 at 12:40
1
Solved
I found unexpected output of following program.
Here pointer ptr point to address of variable i and i hold the value 10. It means the value of ptr also 10. Next ptr increment once. It means now it...
Dialyse asked 25/10, 2019 at 13:25
7
Solved
If I have for example a class with instance method and variables
class Foo
{
...
int x;
int bar() { return x++; }
};
Is the behavior of returning a post-incremented variable defined?
Tin asked 4/3, 2010 at 16:15
14
Solved
Is there a performance difference between i++ and ++i if the resulting value is not used?
Dotted asked 24/8, 2008 at 6:48
5
Solved
I was doing a review of some code and came across an instance of someone post-incrementing a member variable that was a wrapper class around Integer. I tried it myself and was genuinely surprised t...
Pineal asked 7/11, 2012 at 23:32
2
Solved
We cannot use pre-increment on rvalues:
int i = 0;
int j = ++i++; // Compile error: lvalue required
If we define a class:
class A
{
public:
A & operator++()
{
return *this;
}
A operato...
Stultz asked 20/2, 2019 at 1:24
8
My interest is in the difference between for and while loops. I know that the post-increment value is used and then incremented and the operation returns a constant pre-increment.
while (true) {
...
Micrometer asked 28/6, 2013 at 14:19
14
Solved
Can you explain to me the output of this Java code?
int a=5,i;
i=++a + ++a + a++;
i=a++ + ++a + ++a;
a=++a + ++a + a++;
System.out.println(a);
System.out.println(i);
The output is 20 in both c...
Candace asked 3/3, 2010 at 12:21
1 Next >
© 2022 - 2024 — McMap. All rights reserved.