can anyone here who knows where can i find the posted one problem that is to convert the month-day-year birthday to a simple day like sunday?? and who knows the answer to this problem using getdate setdate??

I'm sure the solution is out on the internet somewhere. A little bit of googling can work wonders.

"Explanation" in the comments:

#include <iostream>
#include <ctime>

int main()
{
   /**
    * Fill a struct tm.
    */
   struct tm date = {0};
   date.tm_year = 108; // 2008
   date.tm_mon  = 1;   // February
   date.tm_mday = 19;  // 19
   /**
    * Normalize it.
    */
   time_t normal = std::mktime(&date);
   /**
    * Create a string with the day of the week and print it.
    */
   char text[20];
   std::strftime(text, sizeof text, "%A", &date);
   std::cout << text << '\n';
   /**
    * Extra output to be showy.
    */
   std::cout << asctime(&date) << '\n';

   return 0;
}

/* my output
Tuesday
Tue Feb 19 00:00:00 2008
*/

is that C++ their is plenty of errors and their is no ctime.h in my CPP app. and why don't you use getdate and setdate coz the default time is in my PC??
and where should i put the monday.tues,wed,thur....?

That's standard C++ -- except that I may have missed a std:: on tm , time_t , and asctime .

I'd much rather use that than nonstandard getdate and setdate because the standard stuff is guaranteed to be there whereas the nonstandard stuff is not.

??? i can get it im a begginer i know only the enum, union.. and i dont know st ::? can u please make it's simple plzzzz

using namespace std; When you're not a beginner, unlearn this.

[deleted]

commented: Or how about an umbilical cord? :P +14

who can help to solve this problem using enum(), getdate and setdate?

Getdate

Now first try coming up with something yourself and come back if you encouter problems

how can i use that to solve the problem: how can u convert the month-date-year to a day like monday?

how can u convert the month-date-year to a day like monday?

The complete answer to that question is already given in Dave Sinkula's post in this thread (see http://www.daniweb.com/forums/thread109909.html).
Look at closely the output of his program:

/* my output
[B]Tuesday[/B]
Tue Feb 19 00:00:00 2008
*/

The day of the week (Tuesday) is displayed there. Now just study his code to understand how it works.

@mitrmkar:

You're absolutely right, but the OP wants to use getdate() and setdate() and "Gimme codes pleaze"

who can help me what is the syntax of setdate?..
and who can teach me how to use it tnx

never heard of getdate() and setdate(). But time.h, or ctime, has similar standard C functions getsystime() and setsystime().

[edit]After looking at the link Nick posted I realize they are not the same afterall.[/edit]

@technogeek: (you name is a misnomer). If you scroll down to the bottom of nick's link it will give you a few illstrations how to use that function.

i can't get ancient dragon my teacher teach me that we should use dos.h and struct only how can i use that function and how?

your teacher is an idot then!

open up dos.h in notepad or some other text editor and search for getdate. Here's what you will find: extern void __cdecl getdate( struct date *datep ); That tells you that in order to get the system's date/time you have to pass a pointer to a struct date object that you create. that structure is also defined in that header file.

struct date dt;
getdate(&dt);

Simple, right?? That's all there is to it.

Now do the same with setdate() void _Cdecl setdate (struct date *datep); So to set the date just fill in a struct date and pass a pointer to it to detdate

struct date dt;
// fill in the structure is not shown here.
setdate(&dt);

Again, that is pretty simple stuff and straight forward.

i can't get it again i am newbie in that problem can you help me how to create it that as simple one? using #include<dos.>

If you don't understand it then you are attempting to do something that is over your head. Go back to the beginning of your text book and study the material again. This time do all the problems at the end of each chapter. The two functions getdate() and setdate() require that you know about structures. Study that material very very carefully until you get it straight in your head. Until you do no one in the world can help you very much.

i can't get it again i am newbie in that problem can you help me how to create it that as simple one? using #include<dos.>

why don't you try posting some code for a change ? Look in your textbook and see if you can't figure out how to get the program started with just the include file and main function. That is as basic as it can get.

ok can you help me can i get some sample of your own?

ok can you help me can i get some sample of your own?

Yes we can help you but we will not write the code for you. I think everyone has given you enough information for you to attempt to write the program yourself. You will get no more help from me until you show at least some effort to write the program yourself. Post your code.

ok i will create than soon and will post it when i ma online again bye

ok i will create than soon and will post it when i ma online again bye

Great. I don't be back online for about 8 hours (sleep time for me) so if you post quicker than that maybe someone else cal help you.

#include <dos.h>
#include <process.h>
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
main()
{
struct dosdate_t reset;
struct dosdate_t d;
int y,a,m;

clrscr();
cout<<"year:";  cin>>y;
cout<<"date:";  cin>>a;                        
cout<<"month:"; cin>>m;
  reset.year  =y;
  reset.day   =a;
  reset.month =m;
  system("date");
 cout<<m<<"-"<<a<<"-"<<y;
  _dos_setdate(&reset);
  _dos_getdate(&d);

  printf("The current year is: %d\n", d.year);
printf("The current day is: %d\n", d.day);
printf("The current month is: %d\n", d.month);


  getch();
  return 0;
}

here is my code but i can't get the exact answerr of my question the i try this one

#include <dos.h>
#include <process.h>
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
main()
{int y,x,m;
struct dosdat_t d;
struct date reset;
struct datesave_date
char araw [][10] ={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
clrscr();
getdate(&save_date);
cout<<"Enter year:";cin>>y;
cout<<"Enter month:";cin>>m;
cout<<"Enter day:";cin>>d;
reset.da_year=y;
reset.da_month=m;
reset.da_day=d;
setdate(&reset);
clrscr();
_dos_getdate(&d);getch();
return 0;}

but it can't also solve my problem........... can any one help me

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.