Thread: scanf not working?

  1. #1
    Registered User
    Join Date
    Dec 2019
    Posts
    99

    scanf not working?

    Code:
    #include <stdio.h>
    
    main()
    
    
    {
    
    
    char fistInitial;
    char lastInitial;
    int age;
    int favorite_number;
    
    
    printf("What letter does your first name begin with?\n");
    scanf(" %c", &firstInitial);
    
    
    printf("What letter does your last name begin with?\n");
    scanf("%c", %lastInitial);
    
    
    printf("How old are you?\n");
    scanf("%d", &age);
    
    
    printf("What is your favorite number(integer only)?\n");
    scanf("%d", &favorite_number);
    
    
    printf("\nYour intials are %c.  %c.  and you are %d years old", firstInitial, lastInitial, age);
    printf("\nYour favorite number is %d.  \n\n", favorite_number);
    
    
    return 0;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    }
    Code:
    line 13 error:  'firstInitial' undeclared (first use in this function)
    Any help? Thanks!

  2. #2
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    1,110
    Please compare Lines 9, and 16 in the code listing above.

  3. #3
    Registered User
    Join Date
    Dec 2019
    Posts
    99
    Quote Originally Posted by rstanley View Post
    Please compare Lines 9, and 16 in the code listing above.
    lol! Thank you! You're the bestest!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. scanf not working
    By Danny.Hoshi in forum C Programming
    Replies: 3
    Last Post: 06-17-2015, 11:38 PM
  2. Scanf Working ?
    By Geetika in forum C Programming
    Replies: 12
    Last Post: 12-05-2013, 09:36 AM
  3. scanf not working
    By sourpatchkid in forum C Programming
    Replies: 2
    Last Post: 04-27-2013, 10:10 AM
  4. scanf is not working
    By learning_grc in forum C Programming
    Replies: 9
    Last Post: 11-16-2011, 04:09 PM
  5. Every other scanf not working
    By Rob20050 in forum C Programming
    Replies: 3
    Last Post: 08-31-2007, 12:48 AM

Tags for this Thread