Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int* p = (int*)malloc(sizeof(int));
- *p = 42; // illegal, there isn't an int
- #ifdef __cplusplus
- extern "C" {
- #endif
- int* foo(void);
- #ifdef __cplusplus
- }
- #endif
- #include "foo.h"
- #include <stdlib.h>
- int* foo(void) {
- return malloc(sizeof(int));
- }
- #include "foo.h"
- #include<cstdlib>
- int main() {
- int* p = foo();
- *p = 42;
- std::free(p);
- }
Add Comment
Please, Sign In to add comment