The following code is for printing the elements of a matrix in spiral order. The program works fine. The problem, however, is that the online compiler against which I\'m checkin
You need to suppress the space when you don't need one. You can do it like this:
Add these declarations:
char *format = "%d";
int first_number = 1;
Add this after the first printf:
if (first_number) {
/* Now we want a space between numbers */
first_number = 0;
format = " %d";
}
Change your printf:s to use the new variable:
printf(format, ...);