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

C / C++ / MFC

 
AnswerRe: vc++code for designing a scientific calculator Pin
toxcct9-Oct-07 5:44
toxcct9-Oct-07 5:44 
AnswerRe: vc++code for designing a scientific calculator Pin
Maximilien9-Oct-07 6:45
Maximilien9-Oct-07 6:45 
AnswerRe: vc++code for designing a scientific calculator Pin
Mark Salsbery9-Oct-07 8:12
Mark Salsbery9-Oct-07 8:12 
JokeRe: vc++code for designing a scientific calculator Pin
Hamid_RT9-Oct-07 9:44
Hamid_RT9-Oct-07 9:44 
AnswerRe: vc++code for designing a scientific calculator Pin
Hamid_RT9-Oct-07 9:54
Hamid_RT9-Oct-07 9:54 
GeneralRe: vc++code for designing a scientific calculator Pin
toxcct9-Oct-07 21:25
toxcct9-Oct-07 21:25 
GeneralRe: vc++code for designing a scientific calculator Pin
Hamid_RT10-Oct-07 7:06
Hamid_RT10-Oct-07 7:06 
QuestionTheory question about "void pBuffer" Pin
Nelek9-Oct-07 4:38
protectorNelek9-Oct-07 4:38 
Hi,

When using a buffer to intermediary help to make use of some functions…

If I want to have in the buffer the content of an Array, then I make:

pBuffer = &Array[0];  // or the same: pBuffer = Array;
file->Write (pBuffer , sizeof (Array));


And there is no problem because the array allocates contiguous memory to hold the members and the pointer says where the Array starts, and with the “size of (Array)” I say how many elements have to be written.

But doing the opposite…

::RegQueryValueEx (hWkKey, "SubKey", 0, &dwType, pBuffer, &lnLength); // Read the contents
if (dwType == REG_SZ)	// The registry value is a string, it could be something else though so we better make sure
	szValue = pBuffer;

else if (dwType == REG_BINARY)
	for (int i = 0; i < lnLength; i++)
		Array[i] = *(pBuffer + i);

delete [] pBuffer;
pBuffer = NULL;


The usual assignation works with the string because internally is like a char* and then both uses the start direction to allocate the data in their place till a '\0' is founded, but it should be made using a for when writing the data into the array because there is no way to say how long the array is (like '\0' by the char*) (isn't it?)

Array = *pBuffer;	//error C2440: impossible to convert from 'unsigned char' in 'unsigned char [1252]' 
;	//the fixed size from array makes problems
//or
&Array = pBuffer;	//error C2440: impossible to convert from 'unsigned char *' in 'unsigned char (*)[1252]' 
//or
Array = pBuffer;	//error C2240: impossible to convert from 'unsigned char *' in 'unsigned char [1252]'
//or
&Array[0] = pBuffer;	//error C2109: Left operator must be a "L-Value"
;	//MSDN says "The subscript was used on a variable that was not an array", does it means that a whole array is trying to be placed in one element??


The meaning of the errors (but C2109) and the reason to have them is clear, but...

Is there any other possibility to do it, or the “for” must be used?


Greetings.

--------
M.D.V.

If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?

Help me to understand what I'm saying, and I'll explain it better to you

Wink | ;)

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 
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 

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.