how many times will strlen() be called in this for loop?

后端 未结 6 724
渐次进展
渐次进展 2020-12-03 14:46

Will the strlen() function below get called just once (with the value stored for further comparisons); or is it going to be called every time the comparison is performed?

6条回答
  •  悲&欢浪女
    2020-12-03 15:25

    It will be called for each iteration. The following code only calls strlen function once.

    for (i = 0, j = strlen(word); i < j i++)
    { /* do stuff */ }
    

提交回复
热议问题