Click here to Skip to main content
15,908,834 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Preprocessor Directive Pin
Malli_S31-Jan-11 21:10
Malli_S31-Jan-11 21:10 
QuestionMFC - Printing - Changing page orientation from a custom pagesetup dialog [SOLVED] Pin
Un Suthee31-Jan-11 15:11
Un Suthee31-Jan-11 15:11 
AnswerRe: MFC - Printing - Changing page orientation from a custom pagesetup dialog Pin
Roger Allen2-Feb-11 5:46
Roger Allen2-Feb-11 5:46 
GeneralRe: MFC - Printing - Changing page orientation from a custom pagesetup dialog Pin
Un Suthee3-Feb-11 16:30
Un Suthee3-Feb-11 16:30 
Question2D dynamic wchar array Pin
csrss31-Jan-11 13:30
csrss31-Jan-11 13:30 
AnswerRe: 2D dynamic wchar array Pin
Andrew Brock31-Jan-11 16:41
Andrew Brock31-Jan-11 16:41 
GeneralRe: 2D dynamic wchar array Pin
csrss31-Jan-11 22:35
csrss31-Jan-11 22:35 
AnswerRe: 2D dynamic wchar array [DONE] Pin
csrss1-Feb-11 2:25
csrss1-Feb-11 2:25 
OK, here is how we do it: (once again, Andrew, you rock!)

typedef struct _DatabaseField
{
	DWORD nFieldLen;
	wchar_t pFieldData[];
} DatabaseField;

typedef struct _DatabaseRowEx
{
	DWORD nColumns;
	DatabaseField *pColumns[]; 
} DatabaseRowEx;

int nColumns = 3, x = 0, rowz = 1;

	wchar_t *row1elems[] = {L"aaa", L"bbb", L"ccc"};
	wchar_t *row2elems[] = {L"111", L"222", L"333"};
	DatabaseRowEx *pRow = (DatabaseRowEx *)malloc(sizeof(DatabaseRowEx) + 
		sizeof(DatabaseField) * nColumns * rowz);
	wprintf(L"Row 1: ");
	for(x = 0; x < nColumns; x++)
	{
		pRow[0].pColumns[x] = (DatabaseField *)malloc(sizeof(wchar_t *) * 
			wcslen(row1elems[x]) + 1);
		wcscpy((wchar_t *)pRow[0].pColumns[x], row1elems[x]);
		wprintf(L" [ %s ] ", pRow[0].pColumns[x]);
	}
	wprintf(L"\r\n");

rowz++;

pRow = (DatabaseRowEx *)realloc(pRow, sizeof(DatabaseRowEx) + 
		sizeof(DatabaseField) * nColumns * rowz); 
	wprintf(L"Row 2: ");
	for(x = 0; x < nColumns; x++)
	{
		pRow[1].pColumns[x] = (DatabaseField *)malloc(sizeof(wchar_t *) * 
			wcslen(row2elems[x]) + 1);
		wcscpy((wchar_t *)pRow[1].pColumns[x], row2elems[x]);
		wprintf(L" [ %s ] ", pRow[1].pColumns[x]);
	}
	wprintf(L"\r\n");

011011010110000101100011011010000110100101101110
0110010101110011

AnswerRe: 2D dynamic wchar array [modified] Pin
Emilio Garavaglia31-Jan-11 20:50
Emilio Garavaglia31-Jan-11 20:50 
GeneralRe: 2D dynamic wchar array Pin
csrss31-Jan-11 22:45
csrss31-Jan-11 22:45 
QuestionString array comparison Pin
jharn31-Jan-11 4:48
jharn31-Jan-11 4:48 
QuestionRe: String array comparison Pin
David Crow31-Jan-11 4:57
David Crow31-Jan-11 4:57 
AnswerRe: String array comparison Pin
jharn31-Jan-11 5:08
jharn31-Jan-11 5:08 
AnswerRe: String array comparison Pin
David Crow31-Jan-11 5:41
David Crow31-Jan-11 5:41 
GeneralRe: String array comparison Pin
jharn31-Jan-11 6:09
jharn31-Jan-11 6:09 
GeneralRe: String array comparison Pin
Matthew Barnett1-Feb-11 1:06
Matthew Barnett1-Feb-11 1:06 
AnswerRe: String array comparison Pin
jharn31-Jan-11 5:46
jharn31-Jan-11 5:46 
AnswerRe: String array comparison Pin
David Crow31-Jan-11 6:08
David Crow31-Jan-11 6:08 
GeneralRe: String array comparison Pin
jharn31-Jan-11 6:10
jharn31-Jan-11 6:10 
GeneralRe: String array comparison Pin
jharn31-Jan-11 9:03
jharn31-Jan-11 9:03 
GeneralRe: String array comparison Pin
jsc421-Feb-11 0:13
professionaljsc421-Feb-11 0:13 
QuestionRe: String array comparison Pin
David Crow1-Feb-11 8:51
David Crow1-Feb-11 8:51 
AnswerRe: String array comparison Pin
jsc421-Feb-11 23:36
professionaljsc421-Feb-11 23:36 
AnswerRe: String array comparison Pin
Niklas L31-Jan-11 12:31
Niklas L31-Jan-11 12:31 
GeneralRe: String array comparison Pin
jharn31-Jan-11 12:41
jharn31-Jan-11 12:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.