I have been struggling with this for days. I am to create a program to show a menu of facts, and the user is to put in which fact that they would like to learn about. I have a general idea of how I would like to look. Where I am stuck at is, getting the function to read a file using fgets and print to the screen. This is what I have so far. I just need help getting the textInit function to print to the screen. (Note a lot of this code is trash because i've been changing a lot of things around)proe.c
Code:
#include<stdio.h>
#include<string.h>
#define NUM_ROWS 22
#define LENGTH_OF_LONGEST_LINE 455
void textInit(char readIn[][LENGTH_OF_LONGEST_LINE]); //prototype for textInit function
int displayMenu(char showIn[][LENGTH_OF_LONGEST_LINE]); //prototype for displayMenu function
void inputText(char selectIn[NUM_ROWS][LENGTH_OF_LONGEST_LINE],int choice); // prototype for inputTExt function
int main (void)
{
//int i;
char arraypat[NUM_ROWS][LENGTH_OF_LONGEST_LINE];
char patfact,patfact1;
textInit(arraypat);
patfact1=displayMenu(arraypat);
return 0;
}
void textInit(char readIn[][LENGTH_OF_LONGEST_LINE])//function that will put the input.txt into the array
{
int readIn_1;_
//scanf("%s", &arraypat[NUM_ROWS][LENGTH_OF_LONGEST_LINE]);
fgets(readIn,LENGTH_OF_LONGEST_LINE,stdin);
readIn_1 = strlen(readIn);
//scanf("%s", arraypat[i]);
freopen("/dev/tty","rw",stdin);
//displayMenu(arraypat);
}
int displayMenu(char showIn[][LENGTH_OF_LONGEST_LINE])
{
int i,j,menuChoice;
char read[NUM_ROWS][LENGTH_OF_LONGEST_LINE];
textInit(readIn);
printf("Which of the following St. Pat's Facts do you wish to view?");
for(j=1;j<=11; j++)
{
for(i=1; i<=NUM_ROWS; i+=2)
{
printf("%c",readIn[j][i]);
}
{
scanf("%d", &menuChoice);
if( 1 > menuChoice || menuChoice > 11)
{
printf("Please enter a number between 1 and 11");
}
// return menuChoice;
return 0;
}