Possible duplicate:C programming: is this behavior undefined?
#include<stdio.h> main() { int i=5; printf("%d%d%d",i,i++,++i); }
my expected result is 556. But when I completed it, the result is 767. how?
You cannot be sure that the increments are executed in the expected order, because the instructions inside the arguments are executed in the order chosen by your compiler.
You gain access and change the value to a point in the sequence (changing it twice, infact), within the point of the sequence you cannot be sure that the order of operations.
. , , . i , 5. ++, 6 , ++i, i ..
i
++i
, , . :
int i, j, k; i=j=k=5; printf("%i%i%i",i,j++,++k);
, . , , .
$ gcc -Wall arst.c arst.c:2:1: warning: return type defaults to βintβ arst.c: In function βmainβ: arst.c:5:27: warning: operation on βiβ may be undefined arst.c:5:27: warning: operation on βiβ may be undefined arst.c:6:1: warning: control reaches end of non-void function
.
Source: https://habr.com/ru/post/1763497/More articles:vcs plugin for vim? - vimSubdomains and folders / directories - pythondefine select dropdown with jquery $ (this) - jqueryMap / Zoom out in CouchDB with multiple options? - couchdbRedmine username - ruby-on-railsEmbed HTML in jQuery - jqueryHow to efficiently read a large XML file consisting of a large number of small elements in Java? - javahow can I develop a trap test and a performance test for merging files in different version control systems? - version-controlJava implementation of a rectangle intersection algorithm ..? - javaHow to draw on the web 2.0? - htmlAll Articles