Code:
#include<stdio.h>
#include<stdlib.h>
void print2data(int *p, int rows, int cols, int start);
int main(void)
{
int cols, rows, start;
int *p;
printf("Enter starting value: ");
scanf("%d", &start);
printf("Enter row size: ");
scanf("%d", &rows);
printf("Enter # of rows: ");
scanf("%d", &cols);
p = (int*)malloc (rows * cols * sizeof(int));
print2data(p, rows, cols, start);
system("PAUSE");
}
void print2data(int *p, int rows, int cols, int start)
{
int i, j, end, last;
end = (rows * cols);
rows = end;
last = start + end;
printf("rows*cols = %d\n", end);
printf("start number is %d\n", start);
printf("array is: \n");
for (i = start; i < end; ++i)
{
printf("%d ", i);
}
for(j = start; j < last; ++j)
{
printf("%d ", j);
}
printf("\n");
}
I'm starting to get non garbage numbers that are correct, but they are misplaced. Not sure were to go from here. Any help would be great, thanks.