NOTE It is unsafe to use unbounded functions like strcpy; however, most
programming courses do not cover the dangers posed by these functions. In
fact, if programmers would simply use the safer alternatives??”for example,
strncpy??”then the entire class of buffer overflow attacks would not exist.
Obviously, programmers continue to use these dangerous functions since buffer overflows
are the most common attack vector. That said, even bounded functions can suffer from
incorrect calculations of the width.
for and while Loops
Loops are used in programming languages to iterate through a series of commands multiple
times. The two common types are for and while loops.
A for loop starts counting at a beginning value, tests the value for some condition,
executes the statement, and increments the value for the next iteration. The format is as
follows:
for(
; ; ){
;
}
Therefore, a for loop like:
for(i=0; i<10; i++){
printf("%d", i);
}
will print the numbers 0 to 9 on the same line (since \n is not used), like this:
0123456789. With for loops, the condition is checked prior to the iteration of the statements
in the loop, so it is possible that even the first iteration will not be executed.
Pages:
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280