Hey everyone,
so I have a very simple program here, and somehow I can't get it to print out a two-dimensional array. Any ideas on what I might be doing wrong?
here's my code:
and here's how the printed table should look like when i run the program:Code:#include <stdio.h> #define MAX_PEOPLE 100 char display_table(int table[MAX_PEOPLE][MAX_PEOPLE], int n); int main (void) { int n = 5; char names[MAX_PEOPLE][4] = {"Ami", "Bob", "Cal", "Dan", "Ion"}; int table[MAX_PEOPLE][MAX_PEOPLE] = { {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}, {0, 0, 0, 0, 0}, {1, 0, 1, 0, 1}, {0, 1, 1, 1, 0} }; display_table(table[MAX_PEOPLE][MAX_PEOPLE], n); return 0; } char display_table(int table[MAX_PEOPLE][MAX_PEOPLE], int n) { int row; for (n=0; n<MAX_PEOPLE; n++) { for(row=0; row<MAX_PEOPLE; row++) printf("%d", table[n][row]); } }
Thanks everyone!!Code:|Ami Bob Cal Dan Ion --- --- --- --- --- --- Ami| 0 1 1 1 0 Bob| 0 0 1 0 0 Cal| 0 0 0 0 0 Dan| 1 0 1 0 1 Ion| 0 1 1 1 0



LinkBack URL
About LinkBacks


