Advertisement
GreMendes

Malloc

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