Click here to Skip to main content
15,887,027 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionTheory question about "void pBuffer" Pin
Nelek9-Oct-07 4:38
protectorNelek9-Oct-07 4:38 
AnswerRe: Theory question about "void pBuffer" Pin
led mike9-Oct-07 5:00
led mike9-Oct-07 5:00 
QuestionRe: Theory question about "void pBuffer" Pin
Nelek10-Oct-07 0:27
protectorNelek10-Oct-07 0:27 
AnswerRe: Theory question about "void pBuffer" Pin
led mike10-Oct-07 4:46
led mike10-Oct-07 4:46 
GeneralRe: Theory question about void pBuffer Pin
Nelek10-Oct-07 20:45
protectorNelek10-Oct-07 20:45 
GeneralRe: Theory question about void pBuffer Pin
led mike11-Oct-07 4:59
led mike11-Oct-07 4:59 
GeneralRe: Theory question about void pBuffer Pin
Nelek12-Oct-07 1:59
protectorNelek12-Oct-07 1:59 
AnswerRe: Theory question about "void pBuffer" Pin
Bram van Kampen9-Oct-07 15:31
Bram van Kampen9-Oct-07 15:31 
Don't quite understand the question, but there seems to be confusion about Arrays, Strings and CStrings. An Array is a continguous section of memory of which the compiler is aware of how it is organised.(Element Size, and Number of Elements). It is closely related to the Pointer to an Element Concept. However, whereas you can change a pointer point to a different location in memory, you cannot do this with a variable declared as an array name.[Error C2240] (The Compiler would soon loose track if you could do these things). A Pointer is more versatile than an array in this respect. However, the compiler still keeps track of the type(and hence size) of the object it points to. A pointer to void should be interpreted as a pointer to 'Nothing in Particular' It has only an address value, all other interresting titbits are ommitted. That means that the compiler cannot dereference a void pointer, it has insufficient information to do so. We use a Pointer to void as a generic pointer, which can be passed on by value, but which we must render usable as pointer by adding information, (i.e. Casting)
A String of characters is closely related to an array of characters, there is actually only one difference, when initialised with a literal text constant, the compiler adds automatically a terminating zero to a string. It would for instance not do that if you initialise an array of integers.
This brings us to a CString. Now, this is an entirely different kettle of fish. The items discussed above are essentially C-constructs, which can ofcourse be used in CPP. A CString is firmly a CPP Class, it is definitely NOT the same as a character array. The properties of a CString are not determined by the Compiler (as in Strings and Arrays) but are implemented as part of the Microsoft Standard Libraries. What makes it confusing for a novice is that aparently CStrings and Strings can often be used interchangably, and that the CString can be initialised to the value of a String. This is all due (and purposely designed to work this way) to the gymnastics carried out in the various methods of the CString class. As an example, A CString contains indeed a buffer containing the Null terminated string representing the value. The Cast Operator (LPCSTR) is written in such a way that it returns a pointer to this buffer. I Suggest that you experiment with the CString Class to get a feel for what I am about here. As for your own Array's, why not write your own dedicated class which keeps track of buffers and sizes, and which 'act' like arrays by using the various 'operator' overrides

LateNightsInNewry

GeneralRe: Theory question about "void pBuffer" Pin
Nelek9-Oct-07 22:14
protectorNelek9-Oct-07 22:14 
QuestionMCI -> set video position at a specific time Pin
sdancer759-Oct-07 4:36
sdancer759-Oct-07 4:36 
AnswerRe: MCI -> set video position at a specific time Pin
Hamid_RT9-Oct-07 9:46
Hamid_RT9-Oct-07 9:46 
QuestionRe: MCI -> set video position at a specific time Pin
sdancer7510-Oct-07 0:39
sdancer7510-Oct-07 0:39 
AnswerRe: MCI -> set video position at a specific time Pin
Hamid_RT10-Oct-07 7:09
Hamid_RT10-Oct-07 7:09 
GeneralRe: MCI -> set video position at a specific time Pin
sdancer7510-Oct-07 20:00
sdancer7510-Oct-07 20:00 
GeneralRe: MCI -> set video position at a specific time Pin
Hamid_RT10-Oct-07 21:32
Hamid_RT10-Oct-07 21:32 
QuestionMultiline textout Pin
vSteve9-Oct-07 3:44
vSteve9-Oct-07 3:44 
AnswerRe: Multiline textout Pin
Chris Losinger9-Oct-07 3:51
professionalChris Losinger9-Oct-07 3:51 
GeneralRe: Multiline textout Pin
vSteve9-Oct-07 4:20
vSteve9-Oct-07 4:20 
GeneralRe: Multiline textout Pin
led mike9-Oct-07 5:02
led mike9-Oct-07 5:02 
QuestionBuffer Overrun Pin
LCI9-Oct-07 2:33
LCI9-Oct-07 2:33 
AnswerRe: Buffer Overrun Pin
David Crow9-Oct-07 2:51
David Crow9-Oct-07 2:51 
AnswerRe: Buffer Overrun Pin
Stephen Hewitt9-Oct-07 12:29
Stephen Hewitt9-Oct-07 12:29 
QuestionDirectX - Generall Question Pin
GermanGeorge9-Oct-07 2:05
GermanGeorge9-Oct-07 2:05 
AnswerRe: DirectX - Generall Question Pin
El Corazon9-Oct-07 15:17
El Corazon9-Oct-07 15:17 
GeneralRe: DirectX - Generall Question Pin
GermanGeorge9-Oct-07 20:37
GermanGeorge9-Oct-07 20:37 

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.