Solved

Date/Time

Posted on 1998-05-25
5
192 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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 recursion in the C programming language.

803 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