Advertisement
arthur_arw

Alocação

Oct 4th, 2014
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.  
  7.     int *p;
  8.     int x=1, i;
  9.  
  10.     p=(int *)malloc(sizeof(int));
  11.  
  12.     if (!p)
  13.     {
  14.         printf ("** Erro: Memoria Insuficiente **");
  15.         exit(1);
  16.     }else
  17.  
  18.     while(p!=0)
  19.     {
  20.         scanf("%d", &p);
  21.         x++;
  22.         printf("%d", p);
  23.     }
  24.     for(i=0; i<x; i++)
  25.     {
  26.         printf("\n %d", &p);
  27.     }
  28.     free(p);
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement