Advertisement
GreMendes

Função Alocs

Aug 28th, 2014
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. using namespace std;
  4.  
  5. void alocs(int* x, int tamanho){
  6.  
  7.    
  8.    
  9.     for (int i = 0; i < tamanho; i++){
  10.        
  11.         cout << x[i] << endl;
  12.     }
  13.  
  14.  
  15. }
  16.  
  17.  
  18. int main(){
  19.  
  20.     int *meuarray;
  21.  
  22.     meuarray = (int *)malloc(5 * sizeof (int));
  23.        
  24.    
  25.     meuarray[0] = 5;
  26.     meuarray[1] = 4;
  27.     meuarray[2] = 3;
  28.     meuarray[3] = 2;
  29.     meuarray[4] = 1;
  30.  
  31.     alocs(meuarray, 5);
  32.     free(meuarray);
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement