20 lines
256 B
C++
20 lines
256 B
C++
|
#include <stdlib.h>
|
||
|
|
||
|
// Reallocation
|
||
|
|
||
|
void f() {
|
||
|
char* buf = (char*) malloc(20);
|
||
|
buf[6] = 'x';
|
||
|
buf = (char*) realloc(buf, 9);
|
||
|
int i = 0;
|
||
|
while (i < 12) {
|
||
|
buf[i] = 's';
|
||
|
i++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int main() {
|
||
|
f();
|
||
|
return 0;
|
||
|
}
|