Advertisement
SOIKAT

Untitled

Mar 2nd, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. int *item;
  7. int limit=2,i=0;
  8.  
  9.  
  10. item=(int*)malloc(limit*sizeof(int));
  11. float *price=(float*)malloc(limit*sizeof(float));
  12.  
  13.  
  14. if(item==NULL&&price==NULL)
  15. {
  16. printf("Insufficient Memory, Exiting... \n");
  17. return 0;
  18. }
  19. i=0;
  20.  
  21. *(item+i)=101;
  22. *(price+i)=24.5;
  23. i++;
  24. *(item+i)=103;
  25. *(price+i)=35.8;
  26.  
  27.  
  28. for(i=0; i<limit; i++)
  29. printf("Item=%d Price= %.1f\n",*(item+i),*(price+i));
  30.  
  31.  
  32. free(item);
  33. free(price);
  34.  
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement