Thread: Menu Program

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2017
    Posts
    2

    Menu Program

    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;
    }
    Last edited by Salem; 03-19-2017 at 01:12 AM. Reason: Inlined code for ease of use

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program menu
    By Zaid Mashni in forum C++ Programming
    Replies: 3
    Last Post: 05-15-2016, 09:52 AM
  2. Menu program help
    By Andrew Gaupp in forum C++ Programming
    Replies: 1
    Last Post: 01-03-2014, 09:33 PM
  3. Menu program.
    By Andrew Gaupp in forum C++ Programming
    Replies: 2
    Last Post: 08-20-2013, 07:08 AM
  4. ATM Menu Program
    By worl4125 in forum C++ Programming
    Replies: 3
    Last Post: 08-15-2013, 11:45 PM
  5. Help with menu program
    By leroyjenkens in forum C Programming
    Replies: 1
    Last Post: 06-15-2012, 03:21 PM

Tags for this Thread