?
Solved

Date/Time

Posted on 1998-05-25
5
Medium Priority
?
196 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
kellyjj earned 200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

800 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