Results 1 to 4 of 4

Thread: time.h

  1. #1
    Join Date
    Sep 2011
    Location
    Wandering
    Beans
    75
    Distro
    Ubuntu 10.04 Lucid Lynx

    time.h

    Hi, i am having problem with libraries in c.
    I have to write a program that uses the time.h library (in Borland). My compiler wont recognise these libraries.
    Any suggestions?
    Hint: I wanted the time.h function cause i had to calculate the time that a person enters and leaves a shop.
    Any help is welcome.

  2. #2
    Join Date
    Oct 2011
    Location
    Chicago, IL
    Beans
    419
    Distro
    Xubuntu 10.04 Lucid Lynx

    Re: time.h

    Was time.h not recognized at compile time? or was this a link error?

    compiler statements, error messages, and code always help as well

  3. #3
    Join Date
    Sep 2011
    Location
    Wandering
    Beans
    75
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: time.h

    I actually just got it to work. The problem is it's not working properly. It was suppose to give me the seconds that had passed from 1-1-1970 (i think), but it keeps giving me the same number.

    My code is
    Code:
    #include <stdio.h>
    #include <time.h>
    
    int main()
    {
    	float i;
    	i=time(NULL);
    	printf("seconds passed from 1-1-1970 are %f\n", i);
    	return 0;
    	
    }
    Sorry if it's a stupid mistake i am making it's the first time i use this function.

  4. #4
    Join Date
    Oct 2011
    Location
    Chicago, IL
    Beans
    419
    Distro
    Xubuntu 10.04 Lucid Lynx

    Re: time.h

    Not a stupid mistake, it's probably how printf is formatting i

    try using ctime, and see if the problem persists

    EDIT: When i said ctime, I meant the function in time.h, not the C++ header file. Sorry if that was confusing.
    Last edited by 11jmb; June 4th, 2012 at 03:19 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •