need some c help

Discussion in 'Mac Apps and Mac App Store' started by mikeyredk, Oct 23, 2003.

  1. mikeyredk macrumors 65816

    Joined:
    Mar 13, 2003
    #1
    i want to test my logic before i continue but i keep getting an error after i key in the numbers i really need some help im the only mac user in the class remember its not totally done just want to test some logic

    here is the photo of the first error
    [​IMG]

    if i go into the debug i keep getting bumbed into some other function
    __pow_helper() and it gets stuck

    Code:
    // includes
    #include <iostream.h>
    // defines
    #define SKIPLINE cout<<endl
    void arrange(double,double,double);
    ///////////////////////////////////////////////////////////////////
    //  Programmer:         Manoj Aggarwal
    //  Date Due:           October 19, 2003
    //  Input:              three values
    //  Process:            arrange three values
    //  Output:             three values arranged
    
    int main(){
        //declarations
        
        double a,       // a, b, c are the values that are going
        b,              //      to be arranged
        c;              //      the arrangement values are for the
                        //      output
        
        char
        ans;			//eof check
    
        //main loop
       
        do{
      
            //input
            cout<<"Enter three values to be tested\n";
            cin>>a>>b>>c;
            
            
            //<<<process>>>
            arrange(a,b,c);    
               
            //output
            cout<<""<<a<<" "<<b<<" "<<c<<"\n";
        
            //check for exit
            cout<<"continue? (Y/N) "<<endl;
            do
                ans = toupper(getchar());
     
            while (ans !='Y' && ans != 'N');
            SKIPLINE;
      
        }while (ans == 'Y');
        SKIPLINE;
        //wrap up
     
        cout<<"End of program"<<endl;
        return (0);
    
    }//main()
    //----------------------------------------------
    void arrange( double& a, double& b, double& c){
        double
        high, mid,low;
        if(a <= b and a <= c)
            high = a;
        else if(b >= c)
            low = c;
            
    }
    
    
     
  2. zimv20 macrumors 601

    zimv20

    Joined:
    Jul 18, 2002
    Location:
    toronto
    #2
    your declaration of arrange() doesn't match the function you've defined.

    you declare its arguments as doubles, but the actual definition specifies references to doubles.

    edit: also, check your logic w/in arrange()
     
  3. mikeyredk thread starter macrumors 65816

    Joined:
    Mar 13, 2003
  4. mikeyredk thread starter macrumors 65816

    Joined:
    Mar 13, 2003
    #4
    just one more question
    what is the time equation
     
  5. Vlade macrumors 6502a

    Vlade

    Joined:
    Feb 2, 2003
    Location:
    Meadville, PA
    #5
    Can you be more specific, I don't know what you mean
     
  6. mikeyredk thread starter macrumors 65816

    Joined:
    Mar 13, 2003
    #6
    in turbo c++ there is a function that tells you the current time in seconds

    time_t is the data type
    then you would set it equal to some value
    like
    Code:
    time_t t;
    t = time(null);
    
    this will give you the time in seconds from like 1970
    i need this for a random number generator that we are making in our CSE class
     
  7. applemacdude macrumors 68040

    applemacdude

    Joined:
    Mar 26, 2001
    Location:
    Over The Rainbow
  8. mikeyredk thread starter macrumors 65816

    Joined:
    Mar 13, 2003
  9. MrBubbles macrumors member

    Joined:
    Apr 8, 2003
    Location:
    Mad City
    #9
    use time_t time(time_t *tloc)

    You'll also have to:
    #include <sys/types.h>
    #include <time.h>

    if you need more details check the docs, esp. the man page for the function.
     
  10. Vlade macrumors 6502a

    Vlade

    Joined:
    Feb 2, 2003
    Location:
    Meadville, PA
    #10
    Thats what it's meant to do :p
     

Share This Page