ctime self-implementation trouble

This is a discussion on ctime self-implementation trouble within the C++ Programming forums, part of the General Programming Boards category; Our clock is not a real timer in this program, it is an event counter because the teacher is a ...

  1. #1
    High school loser
    Join Date
    Dec 2004
    Posts
    27

    Angry ctime self-implementation trouble

    Our clock is not a real timer in this program, it is an event counter because the teacher is a freaking retard who does things weirdly. The compiler, however, has decided to add a new file on time.h and/or ctime every time I try to compile. I also get a million errors and it comes from stuff I didn't write and neither did my teammates. Why is the compiler adding this to the program randomly, and how do we make it stop?
    Code:
    int main(int argc, char *argv[]);
    {
    int clock=1;
    int NextTimeF1;
    int NextTimeF2;
    int SchedPersonF1;
    int SchedPersonF2;
    int FALSE;
    bool floor1=FALSE;
    bool floor2=FALSE;
    }
    {
    ElevatorLog open "Elevator_Data", ios::out;
    ElevatorLog<<"-ELEVATOR LOG-";
    int n=1;
        {
            int Write_Line (int ElevatorLog, int n);
            n++;
        }
     ofstream ElevatorLog close();
    system "PAUSE";
    return 0;
    }
     
    void Write_Line (ofstream log, int num);
    {
        log<<num<<"\n";
    }
              
        while (clock <101)
        {
            if (clock %20==0)
            {
                    int NextTimeF1=clock;
                    int NextTimeF2=clock;
               /* NextTimeF1=GeneratePeople(floor1);
                if (NextTimeF1!=0)
                {
                    SchedPersonF1 = clock + NextTimeF1;
                    floor1=TRUE;
                }
                NextTimeF2=GeneratePeople(floor2);
                if (NextTimeF2 !=0)
                {
                    SchedPersonF2=clock +NextTimeF2;
                    floor2=TRUE;
                }*/        
            }
        if (clock ==NextTimeF1)
            FloorBusyF1=TRUE;
        if (clock ==NextTimeF2)
            FloorBusyF2=TRUE;  
        //if clock == ArrivalTime)
        if (arrivaltime==clock)
        {    
            if (ElevatorStatus==FULL)
                {
                ElevatorStatus=EMPTY;
                 void Unload (void);
                }
            else if(dest==1 && floor1==TRUE)
            {
                Load (floor1, SchedPersonF1);
                int SetDestination(int CurrentFloor);
                int SetArrivalTime(int NextTimeF1);
            }    
            else if (dest==2 && floor2==TRUE)
            {
                    Load (floor2, SchedPersonF2)
                    dest SetDestination(dest);
                    int SetArrivalTime (int NextTimeF2);
            }        
        }
    }           
    }

  2. #2
    High school loser
    Join Date
    Dec 2004
    Posts
    27
    P.S. The self-added file isn't included because I'm sick of seeing it. It only appears when I click on the error message in the debugger...

  3. #3
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    I don't know what you're talking about, and I can't find out unless you post some of the errors you're getting. On the other hand, you don't seem to know quite what you're doing:
    Code:
    void Write_Line (ofstream log, int num);
    {
        log<<num<<"\n";
    }
    Very well, it does that one line - but what the heck is all the rest of the code under it, that's completely out of any scope?
    Code:
    int main(int argc, char *argv[]);
    {
    int clock=1;
    int NextTimeF1;
    int NextTimeF2;
    int SchedPersonF1;
    int SchedPersonF2;
    int FALSE;
    bool floor1=FALSE;
    bool floor2=FALSE;
    }
    Your main() does nothing and returns nothing, same problem as above.

    It looks to me like you had a simple mismatching {} problem, and in an attempt to make the compiler errors go away you decided to randomly start adding '}' all over the place. Bad idea, that will never fix anything. Take a close look at your code, and decide where you REALLY want to put your {'s and }'s, fix them up, and then if that doesn't fix your problem then post your compiler errors.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,551
    > int main(int argc, char *argv[]);
    Well that ; pretty much guarantees that it won't compile.

    Saying "this compiler" isn't much use because we've no idea what you're using unless you tell us.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    High school loser
    Join Date
    Dec 2004
    Posts
    27
    Sorry about being confusing and useless. I'm panicking because this is due tomorrow and the teacher hasn't been too helpful for the entire year. We're using Bloodshed.net DevC++ for our compiler.
    We didn't add the brackets randomly, but I agree that there's a definite mess. I'm working on cleaning it up now.
    The out of scope stuff gets moved as soon as I can figure out why DevC++ feels the need to open files I didn't know I asked for. Maybe I did, but I don't think I did.

    A sample of error messages we get:
    40 C:\My Documents\Zoraa stuff\School Projects\Code Stubs.cpp `int clock' redeclared as different kind of symbol
    86 C:\DEV-CPP\include\time.h previous declaration of `clock_t clock()' (I don't believe I actually wrote that)

    Then there's stuff I can deal with myself...
    And I still don't understand why an uninvited file called time.h comes when click on 86 C:\DEV-CPP\include\time.h previous declaration of `clock_t clock()' ...

  6. #6
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,807
    time.h is the header that contains the protypes and other things for using the standard time functions. When your clicking that line it opens the file to show you that clock is already declared there. The compiler thinks you are trying to redefine the clock variable that is already defined by that header you could either change the name of your clock to something else(maybe myClock).
    Woop?

  7. #7
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Right, and the reason it's spitting that error at you is because of:
    >>int main(int argc, char *argv[]);
    If you take the semicolon at the end of that line off, you'll get rid of a boatload of errors.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  8. #8
    High school loser
    Join Date
    Dec 2004
    Posts
    27
    Thanks! That makes more sense than "Just comment it out and it will go away." My teacher needs a kick in the head.

  9. #9
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    While commenting something out is a useful tool for finding out what might be the problem when used properly, it will never work to comment something out as the fix to the problem. You will almost always end up uncommenting anything you've commented for debugging purposes, once you've fixed the real problem.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  10. #10
    High school loser
    Join Date
    Dec 2004
    Posts
    27
    Quote Originally Posted by Hunter2
    While commenting something out is a useful tool for finding out what might be the problem when used properly, it will never work to comment something out as the fix to the problem.
    I agree, but Mr. Johnson seems to think it's a cure-all for everything. That spans from programming to ending world hunger and creating heaven on earth. :P

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. rand() implementation
    By habert79 in forum C Programming
    Replies: 4
    Last Post: 02-07-2009, 12:18 PM
  2. implementation file
    By bejiz in forum C++ Programming
    Replies: 5
    Last Post: 11-28-2005, 12:59 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Pure virtual implementation, or not.
    By Eibro in forum C++ Programming
    Replies: 2
    Last Post: 03-19-2003, 07:05 PM
  5. ctime() error...implementation maybe?
    By [EMOBA] in forum C++ Programming
    Replies: 2
    Last Post: 09-26-2002, 03:57 PM

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