Can't understand NetBeans

This is a discussion on Can't understand NetBeans within the C Programming forums, part of the General Programming Boards category; I'm having trouble understanding what Netbeans is trying to tell me. This isn't Homework at all, just practice. It says ...

  1. #1
    Registered User
    Join Date
    Sep 2012
    Location
    Clemson, SC USA
    Posts
    19

    Can't understand NetBeans

    I'm having trouble understanding what Netbeans is trying to tell me. This isn't Homework at all, just practice. It says that there is a problem with the main () and turns line 43 red, and then a problem with dateUpdate(date today) on line 22. Any ideas?

    Code:
    /* 
     * File:   main.c
     * Author: roberto
     *
     * Created on October 4, 2012, 10:00 AM
     */
    
    #include <stdio.h>
    
    struct date
    {
        int month;
        int day;
        int year;
    };
    
    //Function to Calculate Tomorrow's Date
    
    struct date dateUpdate (struct date today)
    {
        struct date tomorrow;
        int numberOfDays(struct date d); //ONE OF MY PROBLEMS
    
        if (today.date != numberOfDays (today)){
            tomorrow.day = today.day + 1;
            tomorrow.month = today.month;
            tomorrow.year = today.year;
        }
        else if (today.month==12){
            tomorrow.day =1;
            tomorrow.month =1;
            tomorrow.year = today.year +1;
        }
        else {
            tomorrow.day =1;
            tomorrow.month = today.month +1;
            tomorrow.year = today.year;
        }
    return tomorrow;
    }
    
    int main () //ONE OF MY PROBLEMS
    {
        struct date dateUpdate (struct date today);
        struct date thisDay, nextDay;
    
        printf("Enter Today's Date (mm dd yyyy): ");
        scanf("%i%i%i", &thisDay.month, &thisDay.day, &thisDay.year);
    
        nextDay = dateUpdate (thisDay);
        
        printf("Tomorrow's date is %i/%i/%.2i.\n", nextDay.month, nextDay.day, nextDay.year % 100);
    
    return 0;
    }

  2. #2
    Registered User
    Join Date
    May 2012
    Location
    Arizona, USA
    Posts
    383
    I get only one error when compiling your program:
    Code:
    151118.c: In function ‘dateUpdate’:
    151118.c:24:14: error: ‘struct date’ has no member named ‘date’
    The problem looks pretty obvious to me. (If you had posted the exact error message you are getting I wouldn't have had to compile it to find this easy-to-fix error.)

  3. #3
    Registered User ledow's Avatar
    Join Date
    Dec 2011
    Posts
    435
    Code:
    int numberOfDays(struct date d);
    is not a function, but a function prototype. And you've slapped it in the middle of another function, and have no declaration for it anywhere. That's probably what it's whinging about.

    And the main()? That could be a fussy compiler requiring the a specific main() prototype (look in the FAQ's and you'll find it - argc + argv might be expected by the compiler).

    And christop is right in that compiler warnings TELL YOU these things, and that you have a problem on line 24 too.

    - Compiler warnings are like "Bridge Out Ahead" warnings. DON'T just ignore them.
    - A compiler error is something SO stupid that the compiler genuinely can't carry on with its job. A compiler warning is the compiler saying "Well, that's bloody stupid but if you WANT to ignore me..." and carrying on.
    - The best debugging tool in the world is a bunch of printf()'s for everything important around the bits you think might be wrong.

  4. #4
    Registered User
    Join Date
    Sep 2012
    Location
    Clemson, SC USA
    Posts
    19
    I appreciate the feedback, I didn't put in the EXACT code. The code in the book included a function for finding if the given year was a leap year. I apologize for the time wasting, apparently I just need to STUDY..

    Thanks again for all of the feedback, I apologize again for the waste of time and resources.

    Loving these forums more everyday, really do appreciate it.

    Robert

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. netbeans compiles but nothing happens on run
    By DeliriumCordia in forum C Programming
    Replies: 9
    Last Post: 07-06-2012, 08:13 AM
  2. Netbeans and while loop
    By Harry Kashouli in forum C++ Programming
    Replies: 2
    Last Post: 04-03-2012, 06:43 AM
  3. Getting C Compiler for NetBeans
    By Soulzityr in forum C Programming
    Replies: 3
    Last Post: 03-30-2010, 10:00 AM
  4. compiling C++ with NetBeans
    By Furious5k in forum C++ Programming
    Replies: 6
    Last Post: 02-14-2010, 01:38 PM

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