I need some help with a program I'm working on, I have to calculate the cost of a long distance phone call based on the day, time and length of the call. This is what I have so far. I need to figure out how to test what day they are entering and the day is written like this - Mo, Tu, We, Th etc.

#include <iostream.h>

using namespace std;

int main()
	char M[256], day[256];

	cout << "Enter the day you have made your call (enter as Mo, Tu, We, Th, Fr, Sa or Su) "
		 << " the time (in 24 hour notation) the call started and the length of the call." << endl;
	cin.getline (day,256);
	cout << day;

	if (day == "Mo")
		cout << endl << "Monday" << endl;
	cout << "fail";

	return 0;

So right now it fails because it can't check whether the day is Monday.

Better use std::string class:

#include <iostream>
#include <string>
using namespace std;
string day;
if (day == "Mo") ...

To compare C-style strings use strcmp function from <cstring> header:

if (strcmp(day,"Mo") == 0) ...

Now in day == "Mo" you compare pointers (not contents). Of course, you will never get true...

This question has already been answered. Start a new discussion instead.