我正在使用一個指向intger的指針作爲2個Dims數組,我寫了這些代碼,但是我無法獲得整數值。指針指向整數
#include<stdio.h>
#include<conio.h>
void main(void)
{
int **pptr = 0, size = 0, size2 = 0, i, j;
clrscr();
printf("Enter Size of Main Store n");
scanf("%d", &size);
pptr = (int **) malloc(size * sizeof(int *));
printf("Enter Size of Sub Store n");
scanf("%d", &size2);
for (i = 0; i < size; i++) {
pptr[i] = (int *) malloc(size2 * sizeof(int));
}
printf("Enter Values n");
for (i = 0; i < size; i++) {
for (j = 0; j < size2; j++) {
scanf("%dn", pptr[i][j]);
}
}
clrscr();
printf(" Valuesn");
for (i = 0; i < size2; i++, pptr++) {
printf("%dn", *pptr + i);
}
getch();
}
它打印垃圾!
到底是什麼輸出? –