Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- using namespace std;
- int main()
- {
- int x[100];
- cout<<sizeof(x)<<endl;
- int* ptr;
- ptr =(int*)malloc(10 * sizeof(*ptr));
- cout<<static_cast<bool>(ptr==NULL)<<endl;
- for (int i=0;i<10;i++)
- *(ptr+i)=i;
- for (int i=0;i<10;i++)
- cout<<*(ptr+i)<<' ';
- cout<<endl;
- int* ptr2;
- ptr2=(int*)calloc(10,sizeof(int));
- cout<<static_cast<bool>(ptr2==NULL)<<endl;
- *(ptr2+1)=3;cout<<*(ptr2+1)<<endl;
- free(ptr2);
- cout<<*(ptr2+1);
- ptr=(int*)realloc(ptr,10*sizeof(long));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement