Solved

Date/Time

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Where is my core dump file in Ubuntu? 12 442
Adjust Mfcapp 29 160
Inorder binary search tree 5 158
How to install SVN Command Line Client? 5 42
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…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

895 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

13 Experts available now in Live!

Get 1:1 Help Now