fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. static int* getInput(int n){
  5. int* a=0;
  6. int x;
  7. std::cout<<"Enter elements ";
  8. a=new int(n);
  9. for(int i=0;i<n;i++){
  10. std::cin>>x;
  11. a[i]=x;
  12. }
  13. return a;
  14. }
  15.  
  16. int main() {
  17. int *a;
  18. int n=5;
  19. a=getInput(n);
  20. for(int j=0;j<n;j++ )
  21. {
  22. std::cout<<a[j];
  23. }
  24. free(a);
  25. }
Compilation error #stdin compilation error #stdout 0s 3476KB
stdin
1
2
3
4
5
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:24:8: error: ‘free’ was not declared in this scope
  free(a);
        ^
stdout
Standard output is empty