Advertisement
obernardovieira

Copy numbers from int array to int pointer array

Mar 21st, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.26 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main() {
  4.     int numeros[3] = {5,10,15};
  5.     int *pointnum = new int[10];
  6.    
  7.     for(int n=0; n!=10; n++)
  8.         pointnum[n] = (n<sizeof(numeros)/4) ? (numeros[n]) : (0);
  9.    
  10.     for(int d=0; d!=10; d++)
  11.         std::cout << pointnum[d] << std::endl;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement