That a program might run out of memory is one of the simpler ways in which
the physical nature of execution could affect the way we write programs.
Often, the effects are more subtle. Consider the following code,
which is intended to fill an array with integers, starting with zero:
#define ARRAY_SIZE 10
void natural_numbers (void) {
int i;
int array[ARRAY_SIZE];
i = 1;
while (i <= ARRAY_SIZE ) {
printf("%d ",i);
array[i] = i - 1;
i = i + 1;
}
}
When invoked, the procedure natural_numbers will never return. That's right,
never. But it seems pretty harmless, doesn't it? The loop is certainly not an
infinite loop: its index i starts at 1 and ends at ARRAY_SIZE.
Briefly, the problem is that the compiler allocates the variable i to a location
in memory that is right at the end of the memory allocated to array, so that
setting array[10] has the unintended effect of setting the value of i.
- 大小: 3 KB
分享到:
相关推荐
Its peculiarity is that the PathGeometry object is used for animation of the property. The path animations are represented by three classes: DoubleAnimationUsingPath, MatrixAnimationUsingPath, ...
β-Nitroacrylates are an important subclass of nitroolefins in which an ester and a nitro group are simultaneously linked, in α- and β-position, to a double bound. This peculiarity makes these nitro...
- "We noticed the (peculiar) of his manner at once." "peculiar" 应该转化为名词 "特性",即 "peculiarity"。 - "It is quite (remark) that doctors have been so wrong about this." "remark" 应该转化为形容...
在最后,我们看到了一些随机的元素,例如"date of birth"、"mustache"、"solution"、"Hobby"、"SEX"、"motor"、"peculiarity"、"contact"等,这些元素可能是用于设计或动画中的随机元素。 本资源是一个多媒体设计和...
###框架特性 PECULIARITY 1.自定义框架样式,各个部件的颜色、位置包括动画等。 2.采用类UITableView设计方式,使用delegate和dataSouece来定制控件。 3.EYTabbedHeaderView也是可以拿出来单独使用的,用法代码中有...
No attempt has been made to explain the JavaScript syntax used (except in the cases where AngularJS may introduce a peculiarity), nor do we explain concepts such as closures, function chaining, ...
在外网环境中,如果其它两项为false,peculiarity为true,请点击两次GetServerInfo,如果ThreadId自增1,通常这样的数据库不是蜜罐就是被遗忘的数据库 在内网中,如果三项都为false,请换一个IP并尝试用正常的方式连接...
给出了一种基于采样的特异性因子定义,即采样特异性因子(sampled peculiarity factor,SPF),并提出了一种基于SPF的异常检测算法。在真实数据集上进行对比实验,结果表明:该算法在检测异常数据时,精度降低不明显,...