2019-12-01
16:42:32
#include <bits/stdc++.h> #include <stdlib.h> #include <stdio.h> using namespace std; #define maxn 10005 #define M 105 void allocateArray(int **arr,int size,int value){ *arr = (int*)malloc(size * sizeof(int)); printf("%p ",arr); if(*arr != NULL){ for(int i=0;i<size;++i){ *(*arr+i) = value; } } } int main(){ int *vector = NULL; allocateArray(&vector,5,45); printf("%p ",vector); for(int i=0;i<5;++i){ printf("%d ",vector[i]); } system("pause"); return 0; }
#include <bits/stdc++.h> #include <stdlib.h> #include <stdio.h> using namespace std; #define maxn 10005 #define M 105 int (*fptrl)(int); int square(int num){ return num*num; } int main(){ int n = 5; fptrl = square; printf("%d squared is %d ",n,fptrl(n)); system("pause"); return 0; }