blob: 273c1a0ba4ac1621f854001fbe4e2ed57f80d9a4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include <iostream>
#include <vector>
/*
*
* 3.37
*
*
*/
int main () {
const char ca[] = {'H', 'e', 'l', 'l', 'o'/*, '\0'*/};
const char *cp = ca;
while(*cp) {
std::cout << *cp << std::endl;
++cp;
}
/*
* This causes a buffer overflow because there is no null character at the end of the string
* If we put a null-character at the end of the string we don't get an overflow.
*/
return 0;
}
|