Thread: Format String is not a string literal

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jul 2013
    Posts
    2

    Format String is not a string literal

    Hi everyone,

    This is really my first time posting and I'm a newcomer to programming. I'm wondering if someone can point out what i am doing wrong in the if and for loop with choice 2.
    Code:
    
    
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    
    struct employeedatabase
    {
        char firstname[ 20 ];
        char lastname[ 20 ];
        char dateofbirth[ 10 ];
        char ssn[ 11 ];
        char contactnumber[ 13 ];
        unsignedint age[ 2 ];
        char gender[ 6 ];
        double hourlysalary[ 10 ];
    }employees[10];
    
    
    //Function prototype
    int choice = 0;
    int quit = 3;
    int counter = 0;
    int i = 0;
    
    
    int main( )
    {
        printf("\n********** MENU **********\n\n"
               "Enter your choice:\n"
               "1: Add a New Employee to the list.\n"
               "2: Print Current Employees.\n"
               "3: Quit.\n\n" );
    
        printf("Your choice is: ");
        scanf( "%d", &choice);
    
        while(choice !=3)
        {
            if( choice == 1)
    
            {
                printf("\n***** New Employee *****\n");
                printf("\nPlease fill in all information below:\n\n");
    
                printf("First Name: ");
                scanf("%s", employees[counter].firstname);         //input for First Name
    
                printf("Last Name: ");
                scanf("%s", employees[counter].lastname);          //input for Last Name
    
                printf("DOB (MM/DD/YYYY): ");
                scanf("%s", employees[counter].dateofbirth);       //Input for DOB
    
                printf("SSN: ");
                scanf("%s", employees[counter].ssn);               //Input for Social
    
                printf("Telephone Number: ");
                scanf("%s", employees[counter].contactnumber);     //Input for Phone Number
    
                printf("Gender: ");
                scanf("%s", employees[counter].gender);            //Input for Gender
    
                printf("Hourly Salary: $");
                scanf("%lf", employees[counter].hourlysalary);     //Input for Salary
    
                printf("\nEnter your choice:\n"
                       "1: Add a New Employee to the list.\n"
                       "2: Print Current Employees.\n"
                       "3: Quit.\n\n" );
    
                printf("Your choice is: ");
                scanf( "%d", &choice);
    
                if( choice == 1) counter++;// Increments employees by one
    
            }//End of Choice 1
    
    
            if(choice == 2)
    
            {
                printf("\n***** List of Employees *****\n");
                {
                    for(i = 0;i <= 10; i++)
                    {
                        printf(employees[counter].firstname);
                        printf(employees[counter].lastname);
                        printf(employees[counter].dateofbirth);
                        printf(employees[counter].ssn);
                        printf(employees[counter].contactnumber);
                        printf(employees[counter].gender);
                        printf(employees[counter].hourlysalary);
                    }//End of for loop
                }
    
            }//End of Choice 2
    
    
    
        }// End of While Loop
    
    
    
    }// End main
    
    Attached Files Attached Files

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating a C++ std::string literal
    By Subsonics in forum C++ Programming
    Replies: 4
    Last Post: 03-03-2013, 09:57 AM
  2. Modifying a string literal.
    By Eman in forum C++ Programming
    Replies: 45
    Last Post: 12-30-2010, 06:37 PM
  3. question about string literal
    By pangzhang in forum C Programming
    Replies: 6
    Last Post: 07-31-2010, 07:25 AM
  4. Replies: 7
    Last Post: 07-18-2005, 08:43 AM
  5. String literal
    By subdene in forum C++ Programming
    Replies: 5
    Last Post: 11-05-2002, 02:10 PM