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...
By Peter Toft on the 17th of Jul 2007 08:58:46 PM
Download |
Raw |
Embed |
Report
#include <stdio.h>
#include <malloc.h>
void fed(int *a)
{
int ii;
int b;
for (ii=0;ii<3;ii++) {
b=a[ii];
printf("%i\n",b);
}
}
void fed2(int **a)
{
int ii;
int jj;
for (ii=0;ii<2;ii++) {
for (jj=0;jj<3;jj++) {
printf("%i ",a[ii][jj]);
}
printf("\n");
}
}
int main()
{
int *a;
int **b;
int c[2][3];
a=(int *)malloc(3*sizeof(int));
a[0] = 1;
a[1] = 6;
a[2] = 8;
/* Allocate b */
b=(int **)malloc(2*sizeof(int*));
b[0]=(int *)malloc(3*sizeof(int));
b[1]=(int *)malloc(3*sizeof(int));
/* Init b */
b[0][0] = 2;
b[0][1] = -2;
b[0][2] = 22;
b[1][0] = 12;
b[1][1] = -12;
b[1][2] = 212;
/* Init c */
c[0][0] = 2;
c[0][1] = -2;
c[0][2] = 22;
c[1][0] = 12;
c[1][1] = -12;
c[1][2] = -12;
fed(a);
fed2(b);
return 0;
}
Submit a correction or amendment below.
Make A New Post