球員我是新的編程和我很驚訝的後增值的結果,現在我遇到了混亂後,我發現並執行下面的代碼,如果for循環說 1.初始化 2.檢查條件是否爲假終止 3.增量。 我在哪裏發生?我的價值在哪裏等於1?受到困惑,需要明確解釋後增量
int main()
{
int i, j;
for (int i =0; i<1; i++)
{
printf("Value of 'i' in inner loo[ is %d \n", i);
j=i;
printf("Value of 'i' in outter loop is %d \n", j);
// the value of j=i is equals to 0, why variable i didn't increment here?
}
//note if i increments after the statement inside for loop runs, then why j=i is equals to 4226400? isn't spose to be 1 already? bcause the inside statements were done, then the incrementation process? where does i increments and become equals 1?
//if we have j=; and print j here
//j=i; //the ouput of j in console is 4226400
//when does i++ executes? or when does it becomes to i=1?
return 0;
}
如果後增量使用該值並加1?我迷路了...請解釋...非常感謝你。
你的代碼討論外部和內部循環,但是那裏只有一個循環。 –
* 3。增量。我++在哪裏發生?*增量**是**「我++」意味着什麼,它發生在'for'循環的末尾 – tay10r
請閱讀以下鏈接:http://msdn.microsoft.com/en-us/library /b80153d8(v=vs.71).aspx它可以準確解釋你對什麼感到困惑。 – Patashu