I have a program running for a university project (1st year at uni of central lancashire, preston, england baby yeh...
everything works fine, its a carpet shop program that calcs the prices etc then asks for a delivery date....
which it then converts to three strings, and then to integers for seperate day / month / year (need this as it is,
so dont say i should change it...)
cout %26lt;%26lt; "\nPlease enter the preferred date of delivery, in the format DD/MM/YYYY: \n";
cin %26gt;%26gt; Date;
DayStr[0] = Date[0];
DayStr[1] = Date[1];
DayStr[2] = '\0';
^^ same for month and years ^^
i then get the date n time from the system using time_t now;
how can i subtract the currrent date from the delivery date so i can print to be delivered in x days?
any help welcomed :D
How can i subtract delivery date from current date in c++?
Assuming your above program works, which I don't think it will because your doing an aggregate operation on an array..you should assign values to indexes in the array...eg cin %26gt;%26gt; Date[0] or use a for loop or something...regardless since your putting everything in an array anyway simply do something like using a counter variable, personally i think it would be the easiest way of doing something like that.
int counter = 0;
cout %26lt;%26lt; enter day to subtract %26lt;%26lt; endl;
cin %26gt;%26gt; counter;
cout %26lt;%26lt; Date[1] - Date[counter] %26lt;%26lt; endl;
I belive using
Reply:i don't know
teething
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment