Answer the question
In order to leave comments, you need to log in
Why is it bad manners?
This is from K&R:
a[i] = i++; // Значение i при присваивании неопределено
x = func_1() + func_2();
Answer the question
In order to leave comments, you need to log in
Alexey : Evgeny Shatunov :
People who know how to google, but do not understand what they are talking about, give answers! Every day on the toaster!
They can google an article that says about the same thing as the question asked, but, alas, not quite.
And neither in the article nor in the answers does not appear the correct answer.
And the correct answer is in the second, non-obvious part of the clause of the standard describing expressions (C89: 3.3:2, C99: 6.5:2):
Between the previous and next sequence point an object shall have its stored value
modified at most once by the evaluation of an expression. Furthermore, the prior value
shall be read only to determine the value to be stored.
That is, for example, it is not defined here which one will be called first, but it does not matter .
x = func_1() + func_2();
#include <iostream>
int x = 2;
int func_1() {
x *= 10;
return x;
}
int func_2() {
x += 10;
return x;
}
int main() {
std::cout << func_1() + func_2() << std::endl;
return 0;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question