Is there any way to know the system date automatically using a c program ?
If yes please guide me through some codes !!

There functions in <time.h> such as time, localtime, and strftime.

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

int main(void)
{
   time_t now;
   if ( time(&now) != (time_t)(-1) )
   {
      struct tm *mytime = localtime(&now);
      if ( mytime )
      {
         char buffer [ 32 ];
         if ( strftime(buffer, sizeof buffer, "%x", mytime) )
         {
            printf("buffer = \"%s\"\n", buffer);
         }
      }
   }
   return 0;
}

/* my output
buffer = "06/08/05"
*/
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.