fork(1) download
#include <stdio.h>
#define INPUT_FILE 1    //define statements
#define OUTPUT_FILE 2
#define NUM_TO_SHIFT 3
#define ENCODE 4
#define QUIT 0

int menu();     //function prototypes
int input();
int output();
int shift();
int encode();
void quit();

int main()
{
    int choice;     // main variables
    char user_filename[100];

    choice = menu();   // get user's first selection

    while(choice != QUIT)   //execute so long as choice is not equal to QUIT
    {
        switch(choice)
            {
                case INPUT_FILE:
                    printf("Enter the filename of the file to encode:\n");
                    printf("(hit the Enter key when done)\n");
                    //gets(user_filename);
                    scanf("%s", user_filename);
                    printf("Getting %s\n", user_filename);
                    break;
                case OUTPUT_FILE: output();
                    break;
                case NUM_TO_SHIFT: shift();
                    break;
                case ENCODE: encode();
                    break;
                case QUIT: quit();
                    break;
                default:    printf("Oops! An invalid choice slipped through. ");
                            printf("Please try again.\n");
            }
      choice = menu(); /* get user's subsequent selections */
   }

   printf("Bye bye!\n");
   return 0;
}

int menu(void)
{
    int option;

    printf("Text Encoder Service\n\n");
    printf("1.\tEnter name of input file (currently 'Secret.txt')\n");
    printf("2.\tEnter name of output file (currently not set)\n");
    printf("3.\tEnter number of characters data should be shifted (currently +7)\n");
    printf("4.\tEncode the text\n\n");
    printf("0.\tQuit\n\n");
    printf("Make your selection: ");

    while( (scanf(" %d", &option) != 1) /* non-numeric input */
          || (option < 0)               /* number too small */
          || (option > 4))              /* number too large */
    {
      fflush(stdin);                    /* clear bad data from buffer */
      printf("That selection isn't valid. Please try again.\n\n");
      printf("Your choice? ");
    }
    printf("Selecting %d\n", option);
    return option;
}

int input()
{

}

int output()
{
    return 2;
}

int shift()
{
    return 3;
}

int encode()
{
    return 4;
}

void quit()
{
    printf("Quiting...Bye!");
    exit(0);
}
Success #stdin #stdout 0.02s 1724KB
stdin
1
file.txt
2
1
text.txt
0
stdout
Text Encoder Service

1.	Enter name of input file (currently 'Secret.txt')
2.	Enter name of output file (currently not set)
3.	Enter number of characters data should be shifted (currently +7)
4.	Encode the text

0.	Quit

Make your selection: Selecting 1
Enter the filename of the file to encode:
(hit the Enter key when done)
Getting file.txt
Text Encoder Service

1.	Enter name of input file (currently 'Secret.txt')
2.	Enter name of output file (currently not set)
3.	Enter number of characters data should be shifted (currently +7)
4.	Encode the text

0.	Quit

Make your selection: Selecting 2
Text Encoder Service

1.	Enter name of input file (currently 'Secret.txt')
2.	Enter name of output file (currently not set)
3.	Enter number of characters data should be shifted (currently +7)
4.	Encode the text

0.	Quit

Make your selection: Selecting 1
Enter the filename of the file to encode:
(hit the Enter key when done)
Getting text.txt
Text Encoder Service

1.	Enter name of input file (currently 'Secret.txt')
2.	Enter name of output file (currently not set)
3.	Enter number of characters data should be shifted (currently +7)
4.	Encode the text

0.	Quit

Make your selection: Selecting 0
Bye bye!