( Index )
Month

Brief Information about the April '03 CSIG Meeting

Xword -- A Program to Create Crossword Puzzles

B. Arnold

Sample Output

The subject for this month is program that creates crossword puzzles. It is an SDI MFC program written in Visual C++ version 6.0 Foundation Classes.

If you look closely at the sample program display, you may notice that this is not really a crossword diagram. Words are displayed horizontally but not vertically. This is because the program is only half finished. The meeting for this month will discuss the graphical part of the program: How to put the information on the screen and how to interact with the document, view, and frame paradigm. The actual crossword algorithm and coding details will be discussed in May.

Sample Code

void CXwordDoc::Serialize(CArchive& ar)
{
    if (ar.IsStoring())
        {
        // TODO: add storing code here
        }
    else
        {
        // TODO: add loading code here
        CFile* pFile = ar.GetFile ();
        m_nDocLength = pFile->GetLength ();

        // Allocate a buffer for the file data
        try 
            {
            m_pFileData = new char[m_nDocLength];
            }
        catch (CMemoryException* e) 
            {
            m_nDocLength = 0;
            throw e;
            }

        // Read the file data into the buffer
        try 
            {
            pFile->Read (m_pFileData, m_nDocLength);

            if (m_parray)  free(m_parray);
            m_NX = m_NY = 16;
            m_parray = (char *) calloc(m_NX * m_NY, sizeof(char) );

            CString buff;
            char *p=m_pFileData; int i=m_nDocLength;
            for (int y=0; y<m_NY; y++)
                {
                p = getFixedLine(&buff, p, m_NX, m_pFileData+m_nDocLength);
                strncpy(&m_parray[y*m_NX], buff.GetBuffer(20), m_NX);
                }
            }
        catch (CFileException* e) 
            {
            delete[] m_pFileData;
            m_pFileData = NULL;
            m_nDocLength = 0;
            throw e;
            }
    }
}

"Random Access" questions start at 7:30 Tuesday night.

SOURCE CODE

Source Code Files

For help, email me at b a r n o l d @ i e e e . o r g
Back to C++ Main Page