I'm having problems with a little beginners Programm in C, specifically with the Array output.
#include <stdio.h>
#include <stdlib.h>
#define X 10
#define Y 10
void init_world(char (*)[Y][X]);
void next_gen(char (*)[Y][X], char (*)[Y][X]);
void put_world(char (*matrix)[Y][X]);
int main(void)
{
int x=0;
char welt1[X][Y];
char welt2[X][Y];
init_world(welt1);
put_world(welt1);
do
{
next_gen(welt1,welt2);
put_world(welt1);
x++;
}while((welt2!=welt1)and (x<10));
getchar();
return 0;
}
void init_world(char (*welt)[Y][X])
{
...
}
void next_gen(char (*zelle)[Y][X], char (*neu)[Y][X])
{
...
}
void put_world(char (*matrix)[Y][X])
{
int y, x;
for(y=0; y<X; y++)
for(x=0; x<Y; x++)
if(matrix[y][x] != 0)
printf("%c",'*');
else printf("%c",' ');
printf("\n");
printf("\n--------------\n");
}
The last function should print the array elements. This should happen in a maxtrix of '*' or ' ' but it keeps printing these just in lines
******* ***** *************** *** *** *** *** ***
*********************** *** *** *** * *
--------------