Solved

Date/Time

Posted on 1998-05-25
5
190 Views
Last Modified: 2010-05-18
How do I get the system date/time into the heading of a Report file? I'm (really) new to C.
0
Comment
Question by:radamowi
  • 3
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
kellyjj earned 50 total points
ID: 1250952
one way to do it is this:

#include <dos.h>
#include <stdio.h>

int main(void)
{
   struct date d;

   getdate(&d);
   printf("Report Date: %d-%d-%d  \n", d.da_year,d.da_day,d.da_mon);
   return 0;
}
0
 

Author Comment

by:radamowi
ID: 1250953
Your answer was excellent ... BUT ... I forgot to mention I'm running under Unix!
0
 
LVL 2

Expert Comment

by:kellyjj
ID: 1250954
This should work on most UNIX systems.

#include <stdio.h>
#include <time.h>

int main(void)
{
  time_t t;

  time(&t);
  printf("Today's date and time: %s\n", ctime(&t));
  return 0;
}
0
 

Author Comment

by:radamowi
ID: 1250955
I'll try it out as soon as I can ... Which will probably only be tomorrow. I'll let you know how it works out.
0
 

Author Comment

by:radamowi
ID: 1250956
Tried it! Tested it! Like it! "Merci beaucoup", which is French for: "I really appreciate your help in providing me with this solution"!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now