Ive been working on a Game of Life simulator in C for my programming class. Essentially, it needs to take a single line of input and print out a nice grid of x's and o's (representing live cells and dead cells, respectively).
I need to input the grid size, the number of generations to run, if it prints every generation, whether it pauses after each generation, and then the initial configuration on the grid.
To start, here's what I have for the first 5 requirements:
int maxx; int maxy; int gens; char prints; char pauses; scanf( "%d %d %d %c %c", &maxx, &maxy, &gens, &prints, &pauses);
Thats simple enough. But this doesnt account for the last requirement. My question is how to input a string (not just a single character, like the n's) and save it in a character array. Here's what I tried to start:
char input; scanf( "%c\n", &input );
But it only copies one character, and I dont know how to get the whole line of input. Should I be using fget instead of scanf? I think I have the rest of the program working fine, Im just caught up on the input, arguably the most important (And possibly simplest) part.
Ive only had this class for about two weeks, so Im not very proficient in the language. Any prods in the right direction are appreciated! Im asking for just enough to help me understand how to incorporate arrays into my input stream.
Edited by Zaelis: n/a