User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 391,922 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,713 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser:
May 29th, 2007
Views: 1,163
THE program highlights how to create a 2d array in freestore using pointers..
this is my first post so if i commit any fallacies regarding protocol or syntax please forgive me ....
c Syntax | 5 stars
  1. # include <iostream.h>
  2. void main()
  3. { int **a=new int*[10] ;
  4. cout<<"ENter the no of arrays : " ;
  5. int n ;
  6. cin>>n ;
  7. int i,p[5],x=0 ; ;
  8. for(i=0 ; i<n ; i++)
  9. { cout<<"ENter the no. of elements in the "<<i+1<<" array :" ;
  10. cin>>p[x] ;
  11. a[i]=new int[p[x]] ;
  12. for (int j=0 ; j<p[x] ; j++)
  13. { cout<<"enter : " ;
  14. cin >> a[i][j] ;
  15. }
  16. x++ ;
  17. }
  18. x=0 ;
  19. int j ;
  20. for (i=0 ; i<n ; i++)
  21. { for(j=0 ; j<p[x] ; j++)
  22. { cout<<a[i][j]<<" " ;
  23. }
  24. x++ ;
  25.  
  26.  
  27. }
  28. }
Post Comment

Only community members can submit or comment on code snippets. You must register or log in to contribute.

DaniWeb Marketplace (Sponsored Links)
All times are GMT -4. The time now is 8:14 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC