Hello,
I'm an absolute beginner to C. I am studying a module of C programming at University after studying and becoming proficient at Java. I've learn a lot from the examples we have been given, and unerstand how close C and Java are, so I cannot understand why the fucntion "display" in this simple piece of code will not run. When execute, the program reaches this point and stops.
Please don't laugh if I have made some kind of monumental error, my head is swimming and I'm just about ready to scream...
Any input would be gratefully received!
Thanks
Code:
#include <stdio.h>
void display(int mil[10][10])
{
int i, j;
printf("%37s\n", "==Distance Table==");
printf("\n");
printf("%10s","1Ý");
for (i=1; i<10; ++i)
{
printf("%4dÝ", (i+1));
}
printf("\n");
printf("%55s","===================================================");
printf("\n");
for (i=0; i<10; ++i)
{
for (j=0; j<10; ++j)
{
if (mil[i][j]==0)
printf("%4sÝ", "-");
else
printf("%4dÝ", mil[i][j]);
}
printf("\n");
}
printf("%55s\n","-------------------------------------------------");
printf("\n");
}
int main(void)
{
int mil[10][10];
int i, j;
for (i=0; i<10; ++i)
{
for (j=0; j<10-i; ++j)
{
printf("Please enter a distance between points %d and %d: ", (i+1), (j+i+1));
scanf("%d", &mil[i][j+1]);
}
}
for (i=0; i<10; ++i)
{
for (j=0; j<10; ++j)
{
mil[j+i][i]=mil[i][j+i];
}
}
display(mil);
return 0;
}
Sarah