Thread: lil tips

  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    14

    Question lil tips

    since this is a need help page... stuck on a little homework right now.. but just seeing if someone can maybe help me get past this not give me the answer. but in int main i have an Linker error undefined reference to 'print clock'; id returned 1 exit status.

    Code:
    int main(){
        int i;
        double minin,hrin;
        double minout,hrout;
        struct employee clock;
        FILE* fp; 
    scanclock(clock);
    printfclock(clock);
     
     
    system("pause");
    return 0;
    }
    
    
    void printclock(struct employee a){
         
        int i;
        double minin,hrin;
        double minout,hrout;
        FILE* fp; 
         
         fp = fopen("clock.txt", "r");
     
         fprintf(fp, "%s %s %lf %lf %lf %lf", a.first, a.last, minin, hrin, minout, hrout);
         fclose(fp);
        
    }



    That is what i have.. its not the whole code but just where i think the error is coming from. Please and thank you!... like i said im just looking for some aid not the exact answer.

  2. #2
    Registered User
    Join Date
    Sep 2007
    Posts
    1,012
    Check your spellings carefully. You are not calling printclock(), but printfclock(), which does not exist.

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    Remember that C processes a file from top down. Any function or variable must be defined before it can be used. Does your program do this. Where is your function defined, before or after your function call?

    Jim

  4. #4
    Registered User
    Join Date
    Apr 2012
    Posts
    14
    yes it was spelled wrong... its located above int main

    when I compile it shouldn't the information from the file be on the output? cause right its just showing the system("pause") function

  5. #5
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    It should be in the file, not on the console.

    Jim

  6. #6
    Registered User
    Join Date
    Apr 2012
    Posts
    14
    so when i am printing, i am printing to the file? therefor i should have fp= fopen("clock.txt", "w"); instead of "r"?

  7. #7
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    Yes if you want to write to a file you should use a open mode that allows writing, a, a+, r+, w, w+.

    Jim

  8. #8
    Registered User
    Join Date
    Apr 2012
    Posts
    14
    For some reason throwing files into the structs and with functions is jamming me from being able to completely think this program through but thanks for the help im gonna try working the rest out think you have me down the right path.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. tips for c++
    By [SuRaNa] in forum C++ Programming
    Replies: 4
    Last Post: 12-02-2002, 09:30 AM
  2. Tips
    By laughman in forum C++ Programming
    Replies: 5
    Last Post: 10-01-2002, 11:48 AM
  3. A few tips please...
    By gems in forum C++ Programming
    Replies: 4
    Last Post: 04-11-2002, 02:28 PM
  4. Need some tips.
    By arnis in forum Game Programming
    Replies: 3
    Last Post: 03-25-2002, 01:55 PM

Tags for this Thread