hi guys,
This program which is no doubt extremely simple for you people is giving me some headaches. This code below tells you what day it is ,you then type a number and it tells you what day it will be in that many days.
What i am now trying to do is count days ago instead of days ahead.Code:// what the day was yesterday #include <iostream> using namespace std; int main(void) { // declare variables const int week = 7; // days in week int thatday = 0; // the day however long ago int today = 4; // today is 5th day (friday) int daysago = 0; char* weekdays[7] = {"mon","tue","wed","thur","fri","sat","sun"}; do{ // input information cout << endl << endl << "Today is " << weekdays[today] << endl; cout << "How many days forward?" << endl; cin >> daysago; // day was what thatday = (daysago + today) % 7; // % gets remainder cout << weekdays[thatday] << endl; }while(daysago!=0); return 0; }
I thought this would work
thatday = (daysago - today) % 7;
but the program crashes because of the pointer i think.
What is the best way to achieve this.
Thanks



LinkBack URL
About LinkBacks


