Recent Posts
PHP | 9 sec ago
None | 13 sec ago
C++ | 18 sec ago
None | 45 sec ago
None | 48 sec ago
None | 1 min ago
None | 1 min ago
None | 1 min ago
None | 1 min ago
C++ | 2 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Peter Toft on the 17th of Jul 2007 08:58:46 PM Download | Raw | Embed | Report
  1. #include <stdio.h>
  2. #include <malloc.h>
  3.  
  4. void fed(int *a)
  5. {
  6.   int ii;
  7.   int b;
  8.   for (ii=0;ii<3;ii++) {
  9.     b=a[ii];
  10.     printf("%i\n",b);
  11.   }
  12. }
  13.  
  14. void fed2(int **a)
  15. {
  16.   int ii;
  17.   int jj;
  18.  
  19.   for (ii=0;ii<2;ii++) {
  20.     for (jj=0;jj<3;jj++) {
  21.       printf("%i ",a[ii][jj]);
  22.     }
  23.     printf("\n");
  24.   }
  25. }
  26.  
  27. int main()
  28. {
  29.     int *a;
  30.     int **b;
  31.     int c[2][3];
  32.  
  33.     a=(int *)malloc(3*sizeof(int));
  34.     a[0] = 1;
  35.     a[1] = 6;
  36.     a[2] = 8;
  37.  
  38.     /* Allocate b */
  39.     b=(int **)malloc(2*sizeof(int*));
  40.     b[0]=(int *)malloc(3*sizeof(int));
  41.     b[1]=(int *)malloc(3*sizeof(int));
  42.  
  43.     /* Init b */
  44.     b[0][0] = 2;
  45.     b[0][1] = -2;
  46.     b[0][2] = 22;
  47.     b[1][0] = 12;
  48.     b[1][1] = -12;
  49.     b[1][2] = 212;
  50.  
  51.     /* Init c */
  52.     c[0][0] = 2;
  53.     c[0][1] = -2;
  54.     c[0][2] = 22;
  55.     c[1][0] = 12;
  56.     c[1][1] = -12;
  57.     c[1][2] = -12;
  58.  
  59.     fed(a);
  60.     fed2(b);
  61.     return 0;
  62. }
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: