Need help trouble shooting menu PLZ!

This is a discussion on Need help trouble shooting menu PLZ! within the C Programming forums, part of the General Programming Boards category; I have ****ty turbo c and its not a great help any feedback would be most appreciated...

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    28

    Need help trouble shooting menu PLZ!

    I have ****ty turbo c and its not a great help any feedback would be most appreciated
    Attached Files Attached Files
    Cheers

    Bazza

  2. #2
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Location
    Bangalore, India
    Posts
    345
    I the code is small, try pasting only the relevant code instead of uploading the whole file. You'll get faster and usefull tips from people around here.

  3. #3
    Registered User
    Join Date
    Jul 2002
    Posts
    28
    Ok cheers

    TC really sux

    #include <stdio.h>

    void lines_rev(void);
    void chars_rev(void);
    void num_chars(void);
    void num_words(void);
    void num_lines(void);

    void main(void)
    {

    int choice = 0;
    while ((choice = main_menu())!=6)
    {
    switch (choice)
    {
    case 1:num_lines();break;
    case 2:num_words();break;
    case 3:num_chars();break;
    case 4:chars_rev();break;
    case 5:lines_rev();break;
    case 6: exit(1);
    defaultrintf("invalid selection!\n\n");break;
    }
    }
    system ("cls");

    printf("\n\n\n\n\n\n\n\n\t\t ** WELCOME TO THE TEXT FILE ANALYSER **");
    printf("\n\n\n\n\n\n\n\nt\t Please press any key to continue");
    printf("\n\n\n\n\n\n\n\n\n\n\n\n\n SHAUN BARRY 00121738");

    getch();

    system ("cls");
    printf("\n\n\n\t\t\t MAIN MENU\n\n");
    printf("\t\t 1. Count number of lines in file\n");
    printf("\t\t 2. Count number of words in file\n");
    printf("\t\t 3. Count number of characters in file\n");
    printf("\t\t 4. Display file in reverse character order\n");
    printf("\t\t 5. Display file in reverse line order\n");
    printf("\t\t 6. Exit \n");

    Printf("\n\n\t\t Please enter a choice between 1 - 6 :");
    scanf("%d", &choice);

    getch();
    }


    void num_lines(void)
    {
    printf("lines");
    getchar();
    }
    void num_words(void)
    {
    printf("words");
    getchar();
    }
    void num_chars(void)
    {
    printf("chars");
    getchar();
    }
    void chars_rev(void)
    {
    printf("chars rev");
    getchar();
    }
    void lines_rev(void);
    {
    printf("lines rev");
    getchar();
    }

    }
    Cheers

    Bazza

  4. #4
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Location
    Bangalore, India
    Posts
    345
    1.) Use the [CODE] [/ CODE] tags whenever you paste some code.
    2.) What problem are you facing with this code?
    3.) Where is the body of main_menu()?

    It will not even compile, because there's an extra } bracket at the end.

  5. #5
    Registered User
    Join Date
    Jul 2002
    Posts
    28
    As you can guess im a bit of noob the problem I am having with this code is for the menu to activate the sub sections of code

    Thankyou for your interest
    Cheers

    Bazza

  6. #6
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Location
    Bangalore, India
    Posts
    345
    getchar() returns the ASCII value of a character read from the stdin. The ASCII values of 1, 2, 3, ... are 49, 50, 51, ... respectively. So, you can go about with two ways:

    1.) In 'switch(choice) - case' statements, place the numbers in single quotes:
    Code:
    switch (choice)
    {
    case '1':num_lines();break;
    case '2':num_words();break;
    ...
    2.) Switch on ASCII values returned by getchar():
    Code:
    case 49:     /*   '1'   */
                  num_lines(); break;
    case 50:     /*   '2'   */
                  num_words(); break;
    ...

  7. #7
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    > Printf("

    No - printf

    > void main(void)

    int main(void)

    As for your problem, it's really simple (and it's definitely not your compiler - the tool's as useful as the person using it). Think about what you're doing. You have your code to handle input for the menus, and THEN you print the menu out? Try again.

  8. #8
    Registered User
    Join Date
    Jul 2002
    Posts
    28
    Cracked the menu bit now the hard bit the actual function the menu was for thanks for your help guys really appreciated
    Cheers

    Bazza

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 04:25 PM
  2. Replies: 2
    Last Post: 03-05-2009, 10:25 AM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 02:01 AM
  4. Constructive Feed Back (Java Program)
    By xddxogm3 in forum Tech Board
    Replies: 12
    Last Post: 10-10-2004, 04:41 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21