Hi, I have been trying to use a struct to hold some const chars that represent a fixed date

The idea is to select a date on a Month Calendar and compare it to the fixed date in the struct so that a MessageBox can show

typedef struct BASEFULL
{
    char const* bYear(){return "2010";}
    char const* bMonth(){return "October";}
    char const* bLongDay(){return "Saturday";}
    char const* bDay(){return "23";}

} *PBASEFULL;

This is where the comparison is:

SYSTEMTIME chk[2];
                    BASEFULL mch;
                    MonthCal_GetSelRange(hWndMonthCal, chk);

                    char buf3[30];
                    GetDateFormat(NULL, DATE_LONGDATE, &chk[0], NULL, buf3, 30);


                    char buf[100];
                    strcpy(buf, buf3);
                    strcat(buf, " = ");
                    strcat(buf, mch.bLongDay());
                    strcat(buf, ", ");
                    strcat(buf, mch.bDay());
                    strcat(buf, " ");
                    strcat(buf, mch.bMonth());
                    strcat(buf, " ");
                    strcat(buf, mch.bYear());


                    if(mch.bLongDay() == chk[0].wDayOfWeek)
                    {
                        MessageBox(hwndDlg, buf, "MATCH!", 0);
                    }

The comparison has an error: "forbidden comparison between pointer and integer"

If I comment out the "if", the message shows correctly. How can I set the comparison up correctly?

Please forgive me if I am being confusing but I am a newbie in win32 and c++
Please help me figure things out with this error.

You could try having a mapping of strings to numbers and upon entering a string as the key the map returns the value as an integer that the day represents.

What does that mean? How do I do a mapping of strings?

The following code is an example of how you could use a map to solve your problem.

#include <iostream>
#include <map>
#include <string>
#include <Windows.h>

using namespace std;


int main(){

	map<string, WORD> myMap; // map where "strings" are used as keys and 16-bit ints are returned
	string arr[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
	map<WORD, string> reverseMap; // just for convenience
	enum {DOW = 7};

	for(int i = 0; i < DOW; i++){
		myMap.insert(pair<string, WORD>(arr[i] , static_cast<WORD>(i) ));
		reverseMap.insert(pair<WORD, string>(static_cast<WORD>(i), arr[i]));
	}

	for( map<string, WORD>::iterator it = myMap.begin(); it != myMap.end(); it++)
		cout << (*it).first << " => " << (*it).second << endl;

	WORD dayOfWeek = static_cast<WORD>(5);

	if( myMap["Saturday"] == dayOfWeek)
		cout << "Today is Saturday!" << endl;
	else{

		cout << "Today is not Saturday, but it is " << reverseMap[dayOfWeek] << "!"<< endl;
	}



	cin.get();
	return 0;
}

Woah! That is waaay too complex.

I did find a solution though: I just used SYSTEMTIME members and assigned values to the ones I needed. Now my code is much simpler.

But thanks anyway for at least giving me a reason to rethink my approach...

hi i need a an algorithm for spellchecker in data structures using trees

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.