Write the low-order 8 bits of the time to the disk file

This is a discussion on Write the low-order 8 bits of the time to the disk file within the C Programming forums, part of the General Programming Boards category; Hello, I'm writing a c program for class and it's asking me to write the low-order 8 bits of the ...

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    1

    Write the low-order 8 bits of the time to the disk file

    Hello, I'm writing a c program for class and it's asking me to write the low-order 8 bits of the time to the disk file. We are supposed to use the time system call and then write it to a file.

    Currently i have everything working doing this:

    unsigned char c;

    c = 0xae;

    write(fd, &c, 1);

    and to get the time I'm using: time_t time(time_t *timer);

    my question is how do i save time to c?

    something like: c = time; so i can write it to the file...

    Any help would be great, thanks.

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    2,703
    Look up Bit-wise And operator

  3. #3
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by kfuller002 View Post
    Hello, I'm writing a c program for class and it's asking me to write the low-order 8 bits of the time to the disk file. We are supposed to use the time system call and then write it to a file.

    Currently i have everything working doing this:

    unsigned char c;

    c = 0xae;

    write(fd, &c, 1);

    and to get the time I'm using: time_t time(time_t *timer);

    my question is how do i save time to c?

    something like: c = time; so i can write it to the file...

    Any help would be great, thanks.
    Couple of things...
    1) check the FAQs for this site... and please use code tags when posting code.
    2) If you're going to ask for help, please show us the code you are having trouble with, not a bunch of fragments that mean nothing.

    For your question...
    Code:
    int c = time(0) & 0xFF;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  2. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 07:51 PM
  3. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  4. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM
  5. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 02:58 PM

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