/* Spring 2023 - Lab 6

   program that will read in the text from a file, 
	using redirection, into a 2-D array, and:
		1. count the number of lines in the file (textInit(), this file)
		2. print the text back out to the user (textPrint(), this file)

*/


#include <stdio.h>
// #include <string.h>


#define MAX_LINE 200
#define MAX_LINE_LEN 100

int main(void) {
	char theText[MAX_LINE][MAX_LINE_LEN];
	int i = 0, j, k, numLines = 0, wordCount = 0, occurences = 0;

	// fill up array with lines from file
	while ((fgets(theText[i], MAX_LINE_LEN, stdin) != NULL)) {
		i++;
	}

	// the value of i is the number of lines
	numLines = i;
	printf("\nThis poem has %d lines.\n\n", numLines);

	// print the array
	for (i = 0; i < numLines; i++) {
		/* for (j = 0; theText[i][j] != '\n'; j++) {
			printf("%c", theText[i][j]);
		}
		printf("\n"); */
		printf("%s", theText[i]);
	}
	
	return 0;
}








