Thread View: comp.os.ms-windows.programmer.tools.mfc
3 messages
3 total messages
Started by iti
Tue, 23 Jan 1996 23:29
HELP !!! Memory - Allocation
Author: iti
Date: Tue, 23 Jan 1996 23:29
Date: Tue, 23 Jan 1996 23:29
18 lines
1040 bytes
1040 bytes
I am using Visual C++ to write a Windows Application - and I am having a memory problem. I want to dynamically allocate "nTemp" bytes of memory to read in a char string, or the most memory available up to "nTemp" bytes. My questions being: 1. How can I most efficiantly do this? 2. Should I use -> pChar = (char*) malloc(nTemp); Or -> pChar = new char[nTemp]; Please send any advice you have for me to my EMail address: iti@netvision.net.il Thanks Yaakov
Re: HELP !!! Memory - Allocation
Author: ebennett
Date: Thu, 25 Jan 1996 04:01
Date: Thu, 25 Jan 1996 04:01
20 lines
1257 bytes
1257 bytes
iti@Jerusalem.netvision.net.il wrote: >I am using Visual C++ to write a Windows Application - and I am having >a memory problem. I want to dynamically allocate "nTemp" bytes of memory >to read in a char string, or the most memory available up to "nTemp" >bytes. >My questions being: > 1. How can I most efficiantly do this? > 2. Should I use > -> pChar = (char*) malloc(nTemp); Or > -> pChar = new char[nTemp]; Personal Opinion: If you are using C++, use C++. (i.e., go with new instead of malloc). The only technical reason for this is to make sure object constructors are called when allocating an array of objects. In this case it really does not matter, but I would avoid using malloc in C++ code. Earl Bennett
Re: HELP !!! Memory - Allocation
Author: Programmer
Date: Sun, 28 Jan 1996 01:54
Date: Sun, 28 Jan 1996 01:54
27 lines
1297 bytes
1297 bytes
iti@Jerusalem.netvision.net.il wrote: : I am using Visual C++ to write a Windows Application - and I am having : a memory problem. I want to dynamically allocate "nTemp" bytes of memory : to read in a char string, or the most memory available up to "nTemp" : bytes. : My questions being: : 1. How can I most efficiantly do this? : 2. Should I use : -> pChar = (char*) malloc(nTemp); Or : -> pChar = new char[nTemp]; : Please send any advice you have for me to my EMail address: : iti@netvision.net.il : Thanks : Yaakov Hello: It is highly recommended using the "new" operator when using C++. It is both practical and effifienct. Ronski
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads