Thread: not compiling, not sure how to fix errors

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

    not compiling, not sure how to fix errors

    Code:
    #define KIDS 3#define FAMILY "The Paytons"
    #define MORTAGE_RATE 5.15
    It's a saved .h file.

    Then there is this code:

    Code:
    #include <stdio.h>#include <string.h>
    #include "first.h"
    
    
    main()
    
    
    {
    
    
    
    
    
    
    int age;
    char childname[14] = "Thomas";
    
    
    printf("\n%s have %d kids.\n", FAMILY, KIDS);
    
    
    age= 11;
    printf("The oldest, %s, is %d.\n", childname, age);
    age = 6;
    printf("The middle boy, %s, is %d.\n", childname, age);
    
    
    age = 3;
    
    
    strcpy(childname, "Ben");
    printf("The youngest, %s, is %d.\n, childname, age);
    
    
    return 0;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    }
    Code:
    line 24:  error:  missing terminating " character
    
    line 26: error:  expected expression before 'return'
    
    line 40:  error:  expected ';'  before '}' token
    Any help would be appreciated. Thanks!

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,560
    You forgot the closing double quote for the string constant on this line:
    Code:
    printf("The youngest, %s, is %d.\n, childname, age);
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Dec 2019
    Posts
    46
    Quote Originally Posted by laserlight View Post
    You forgot the closing double quote for the string constant on this line:
    Code:
    printf("The youngest, %s, is %d.\n, childname, age);
    Code:
    printf(the youngest, %s, is %d.\n, childname, age));
    Like that?

  4. #4
    Registered User
    Join Date
    Dec 2019
    Posts
    46
    Please forgive me, I get like this when I am doing something challenging(for me). I put the " at the place you said, and, yes, it compiled. Thank you!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with errors in compiling
    By m-kosier in forum C Programming
    Replies: 5
    Last Post: 11-29-2011, 06:31 PM
  2. Errors after compiling
    By CroBoss in forum C++ Programming
    Replies: 3
    Last Post: 06-09-2010, 10:21 AM
  3. c++ compiling errors... very odd!
    By renderstream in forum C++ Programming
    Replies: 9
    Last Post: 03-07-2004, 05:39 PM
  4. errors when compiling, but I don't know what they mean
    By indigo0086 in forum C++ Programming
    Replies: 7
    Last Post: 11-04-2002, 02:50 PM

Tags for this Thread