Click here to Skip to main content
15,914,163 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionOverriding Functions with variable argument list. Pin
Suyash28-Mar-06 4:22
Suyash28-Mar-06 4:22 
AnswerRe: Overriding Functions with variable argument list. Pin
toxcct28-Mar-06 5:09
toxcct28-Mar-06 5:09 
Questioncredentials Pin
RomTibi28-Mar-06 4:20
RomTibi28-Mar-06 4:20 
QuestionWriting 64-bit code with VS 2005 Standard ? Pin
Defenestration28-Mar-06 4:19
Defenestration28-Mar-06 4:19 
AnswerRe: Writing 64-bit code with VS 2005 Standard ? Pin
Defenestration28-Mar-06 4:30
Defenestration28-Mar-06 4:30 
GeneralClicket police! Pin
Trollslayer28-Mar-06 7:26
mentorTrollslayer28-Mar-06 7:26 
QuestionProfiling code in VC++ 2005 ? Pin
Defenestration28-Mar-06 4:16
Defenestration28-Mar-06 4:16 
QuestionHow to pass array as a reference parameter? Pin
Ming Luo28-Mar-06 3:18
Ming Luo28-Mar-06 3:18 
Hi all:
Does anybody know how to pass an array as a reference parameter? When the procedure terminates, the content in the array are modified. For example:
<br />
float* ScaleVector(float *src, float deltaT){<br />
	float *ret = new float[6*p.n];<br />
	float *head = ret;<br />
<br />
	for (int i = 0; i < p.n; i++){<br />
		//*(ret++) = *(src++)*deltaT;	<br />
		float vx = *(src++);		// velocity on x axis<br />
		float vy = *(src++);		// y axis<br />
		float vz = *(src++);		// z axis<br />
		float ax = *(src++);		// acceleration on x axis<br />
		float ay = *(src++);		// y axis<br />
		float az = *(src++);		// z axis<br />
		*(ret++) = vx * deltaT + 0.5 * ax * deltaT * deltaT;		// calculate the displacement at x axis<br />
		*(ret++) = vy * deltaT + 0.5 * ay * deltaT * deltaT;		// y axis<br />
		*(ret++) = vz * deltaT + 0.5 * az * deltaT * deltaT;		// z axis<br />
		*(ret++) = ax * deltaT;			// added speed at x<br />
		*(ret++) = ay * deltaT;			// y<br />
		*(ret++) = az * deltaT;			// z<br />
	}<br />
	return head;<br />
}<br />

Because this piece of code will be looped thousand times, it keeps on allocating memories to the temporary array *ret. This leads to the memory leaking of my system. How can I find a way to make a procedure to do the job by modifying the content of the array "*src" passed in instead of returning a separate array please??
Thanks in advance!!!

Asura
AnswerRe: How to pass array as a reference parameter? Pin
toxcct28-Mar-06 3:37
toxcct28-Mar-06 3:37 
AnswerRe: How to pass array as a reference parameter? Pin
BadKarma28-Mar-06 3:53
BadKarma28-Mar-06 3:53 
AnswerRe: How to pass array as a reference parameter? Pin
khan++28-Mar-06 3:57
khan++28-Mar-06 3:57 
QuestionCreateProcess Pin
ilgale28-Mar-06 3:12
ilgale28-Mar-06 3:12 
AnswerRe: CreateProcess Pin
Hamid_RT28-Mar-06 3:20
Hamid_RT28-Mar-06 3:20 
GeneralRe: CreateProcess Pin
ilgale28-Mar-06 3:25
ilgale28-Mar-06 3:25 
GeneralRe: CreateProcess Pin
Rage28-Mar-06 3:39
professionalRage28-Mar-06 3:39 
GeneralRe: CreateProcess Pin
ilgale28-Mar-06 3:48
ilgale28-Mar-06 3:48 
GeneralRe: CreateProcess Pin
Rage28-Mar-06 3:59
professionalRage28-Mar-06 3:59 
GeneralRe: CreateProcess Pin
ilgale28-Mar-06 4:06
ilgale28-Mar-06 4:06 
GeneralRe: CreateProcess Pin
khan++28-Mar-06 4:12
khan++28-Mar-06 4:12 
GeneralRe: CreateProcess Pin
ilgale28-Mar-06 4:15
ilgale28-Mar-06 4:15 
GeneralRe: CreateProcess Pin
khan++28-Mar-06 4:26
khan++28-Mar-06 4:26 
QuestionMessage encryption and splitting Pin
cjsin28-Mar-06 2:05
cjsin28-Mar-06 2:05 
AnswerRe: Message encryption and splitting Pin
Rage28-Mar-06 4:06
professionalRage28-Mar-06 4:06 
Questionvmr9.h Pin
William Burton28-Mar-06 1:16
William Burton28-Mar-06 1:16 
AnswerRe: vmr9.h Pin
Saurabh.Garg28-Mar-06 1:33
Saurabh.Garg28-Mar-06 1:33 

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.