I want to be clear, yes, this is a homework question, and I do not expect you to do my homework for me. I like coding and I'm just looking for advice.
Having said that, I create a Game of Life in C. Here is some code to show that I was working on it:
void create_area(void){ int table[24][80]; int i,j; int xvalue=10,yvalue=10; table[10][10] = 2; /*for(j=0; j<24; j++){ for(i=0; i<80; i++){ table[j][i] = 1; } }*/ for(j=0; j<24; j++){ for(i=0; i<80; i++){ printf(" ",table[j][i]); } printf("\n"); } /*if(xvalue=10){ if(yvalue=10){ printf("O", table[xvalue][yvalue]); } }*/ /*for(j=0; j<24; j++){ for(i=0; i<80; i++){ if(xvalue=0){ if(yvalue=0){ printf("O",table[xvalue][yvalue]); } } } }*/ }
My main method is not shown here, but it takes care of finding the number of arguments and argument strings and puts them in the coordinates with the two arrays that I create (x_array and y_array). The above method basically creates a grid in the terminal. The options for create_area are not valid yet (because I just want to check the values ββto see if this works, so I have two int variables: xvalue and yvalue). But the idea is that create_area will take the value x and the value y and initialize the character "O" where the cell starts. Most of the code is commented out because I'm trying to figure out what is going on.
My question is . How to insert a character into my 2d array so that it displays that character in a place on the grid when viewing it in the terminal?
So far I have created my 2d array and used two loops to go through it and print spaces. But I'm trying to figure out how to print char, for example, in table [10] [10]. I tried several things, but the character will not be displayed in a specific place, only in the lower left corner of the screen. I think I missed something simple.
Any help would be appreciated.
source share