Click here to Skip to main content
15,886,753 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: modulus operator Pin
thathvamsi12-Jul-06 17:36
thathvamsi12-Jul-06 17:36 
AnswerRe: modulus operator Pin
Naveen12-Jul-06 17:41
Naveen12-Jul-06 17:41 
GeneralRe: modulus operator Pin
thathvamsi12-Jul-06 18:06
thathvamsi12-Jul-06 18:06 
GeneralRe: modulus operator Pin
Naveen12-Jul-06 18:17
Naveen12-Jul-06 18:17 
Questionhelp useing Microsoft HTML Object Library in visual c++ 6 Pin
method00712-Jul-06 12:14
method00712-Jul-06 12:14 
AnswerRe: help useing Microsoft HTML Object Library in visual c++ 6 Pin
nguyenvhn12-Jul-06 17:32
nguyenvhn12-Jul-06 17:32 
GeneralRe: help useing Microsoft HTML Object Library in visual c++ 6 Pin
method00712-Jul-06 17:47
method00712-Jul-06 17:47 
QuestionC++ memory question Pin
mdexch12-Jul-06 11:59
mdexch12-Jul-06 11:59 
The following program doesn't free all the memory. Can any one tell me what is wrong with the code?

Thanks.

//
wchar_t *pwcTest = L"Test";
int g_I=1000;
void AllocateMem(wchar_t ***pwcArray)
{
*pwcArray = (wchar_t**)new wchar_t*[g_I+1];
ZeroMemory(*pwcArray, sizeof(wchar_t*)*g_I+1);
for(int i=0; i<g_I; i++) {
(*pwcArray)[i] = (wchar_t*)new wchar_t[wcslen(pwcTest)+1];
wcscpy((*pwcArray)[i], pwcTest);
}
(*pwcArray)[i] = NULL;
}

void FreeArray(wchar_t **pwcDC)
{
if(pwcDC != NULL) {
for(int i=0; pwcDC[i] != NULL; i++)
delete [] pwcDC[i];
delete [] pwcDC;
}
}

int main( int argc, char *argv[ ])
{
char s[2];

printf("main:\n");
fscanf(stdin, "%s", s);
// Mem Usage (in the Windows Task Manager): 632K

wchar_t **pwcArray = NULL;

for (int i=0; i<1000; i++) {
AllocateMem(&pwcArray);
FreeArray(pwcArray);
}
printf("main: %d\n", i);
fscanf(stdin, "%s", s);
// Mem Usage: 688K (g_I=1000)
// Mem Usage: 908K (g_I=10000)

return 0;
}
//

mdexch
AnswerRe: C++ memory question [modified] Pin
earl12-Jul-06 13:11
earl12-Jul-06 13:11 
GeneralRe: C++ memory question Pin
mdexch14-Jul-06 7:58
mdexch14-Jul-06 7:58 
AnswerRe: C++ memory question Pin
Joe Woodbury12-Jul-06 14:11
professionalJoe Woodbury12-Jul-06 14:11 
GeneralRe: C++ memory question Pin
kanduripavan12-Jul-06 20:46
kanduripavan12-Jul-06 20:46 
GeneralRe: C++ memory question Pin
Joe Woodbury13-Jul-06 0:11
professionalJoe Woodbury13-Jul-06 0:11 
Questionsscanf will only put value in first variable Pin
Evilpixie12-Jul-06 11:32
Evilpixie12-Jul-06 11:32 
AnswerRe: sscanf will only put value in first variable [modified] Pin
earl12-Jul-06 12:46
earl12-Jul-06 12:46 
GeneralRe: sscanf will only put value in first variable Pin
Evilpixie12-Jul-06 13:11
Evilpixie12-Jul-06 13:11 
GeneralRe: sscanf will only put value in first variable Pin
earl12-Jul-06 13:14
earl12-Jul-06 13:14 
GeneralRe: sscanf will only put value in first variable Pin
Evilpixie12-Jul-06 13:17
Evilpixie12-Jul-06 13:17 
AnswerRe: sscanf will only put value in first variable Pin
Stephen Hewitt12-Jul-06 14:08
Stephen Hewitt12-Jul-06 14:08 
QuestionColor management in CDC Pin
TchouTchou Project12-Jul-06 11:23
TchouTchou Project12-Jul-06 11:23 
AnswerRe: Color management in CDC Pin
A_Fa12-Jul-06 20:09
A_Fa12-Jul-06 20:09 
QuestionHow can I convert to TIFF file format? [modified] Pin
Cris12-Jul-06 9:47
Cris12-Jul-06 9:47 
AnswerRe: How can I convert to TIFF file format? Pin
Christian Graus12-Jul-06 9:55
protectorChristian Graus12-Jul-06 9:55 
AnswerRe: How can I convert to TIFF file format? Pin
Joe Woodbury12-Jul-06 10:28
professionalJoe Woodbury12-Jul-06 10:28 
GeneralRe: How can I convert to TIFF file format? Pin
Cris13-Jul-06 2:00
Cris13-Jul-06 2:00 

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.