Solved

Date/Time

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem to ASCII 1 197
Grammars for C C++ and java 1 131
What is sub-make ? 2 71
Windows 2012 R2 -- create 3.5TB GPT from unallocated space ? 1 55
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…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand opening and reading files 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.

828 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