Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4583700
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:15:05+00:00 2026-05-21T21:15:05+00:00

I am working with batches of files that contain information about the same object

  • 0

I am working with batches of files that contain information about the same object at the different times of its life, and the only way to order them is by creation date.
I was using this:

//char* buffer has the name of file
struct stat buf;
FILE *tf;
tf = fopen(buffer,"r");
//check handle
fstat(tf, &buf);
fclose(tf);
pMyObj->lastchanged=buf.st_mtime;

But that does not seems to work.
What am I doing wrong? Are there other, more reliable/simple ways to get file creation date under Linux?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T21:15:06+00:00Added an answer on May 21, 2026 at 9:15 pm

    fstat works on file descriptors, not FILE structures. The simplest version:

    #include <sys/types.h>
    #include <sys/stat.h>
    #include <stdio.h>
    
    #ifdef HAVE_ST_BIRTHTIME
    #define birthtime(x) x.st_birthtime
    #else
    #define birthtime(x) x.st_ctime
    #endif
    
    int main(int argc, char *argv[])
    {
            struct stat st;
            size_t i;
    
            for( i=1; i<argc; i++ )
            {
                    if( stat(argv[i], &st) != 0 )
                            perror(argv[i]);
                    printf("%i\n", birthtime(st));
            }
    
            return 0;
    }
    

    You will need to figure out if your system has st_birthtime in its stat structure by inspecting sys/stat.h or using some kind of autoconf construct.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with a postgreSQL database that gets updated in batches. I need
I'm working on a small console utility to upload batches of data to our
Working with an undisclosed API, I found a function that can set the number
Working with JSF 2.0 (and Primefaces), is there a way to fire an ActionListener
When I first started working at the company that i work at now, I
My software uses multiple threads to do its work. There is a pipeline that
I am working on a project that I have to Write a simple script
I'm working on an application that may generate thousands of messages in a fairly
Working with liferay it's always says about portal in response: Liferay-Portal:Liferay Portal Community Edition
working on xcode I realized that if I create a non-void method, I call

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.