Click here to Skip to main content
15,900,110 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Opinion about Notify Icon Pin
Mark Salsbery13-Jan-08 8:16
Mark Salsbery13-Jan-08 8:16 
GeneralRe: Opinion about Notify Icon Pin
Richard Andrew x6413-Jan-08 8:40
professionalRichard Andrew x6413-Jan-08 8:40 
QuestionRe: Opinion about Notify Icon Pin
David Crow14-Jan-08 2:34
David Crow14-Jan-08 2:34 
GeneralRe: Opinion about Notify Icon Pin
Mark Salsbery14-Jan-08 6:08
Mark Salsbery14-Jan-08 6:08 
GeneralNewbie Question on C Pointers Pin
_NielsB12-Jan-08 10:55
_NielsB12-Jan-08 10:55 
GeneralRe: Newbie Question on C Pointers Pin
Chris Losinger12-Jan-08 11:03
professionalChris Losinger12-Jan-08 11:03 
GeneralRe: Newbie Question on C Pointers Pin
CPallini12-Jan-08 11:58
mveCPallini12-Jan-08 11:58 
GeneralRe: Newbie Question on C Pointers Pin
_NielsB12-Jan-08 21:29
_NielsB12-Jan-08 21:29 
Hello again!
Thank you for your adwises Smile | :)
The real task I want to test is to append buffB to buffA. Asume there is a function-call that gives me 2 pointers to buffers (p_buffA and p_buffB) and the size of each of them (n_A and n_B). The function should retur the new pointer to buffA and the new size (f.e. saved in a struct).

Now I am using c++ new / delete to allocate and free memory.

<br />
// buffA<br />
int n_A = 30; <br />
char* p_buffA = new char[n_A];<br />
memset(p_buffA, (int)'a', n_A);<br />
<br />
// buffB<br />
int n_B = 50;<br />
char* p_buffB = new char[n_B];<br />
memset(p_buffB, (int)'b', n_B);<br />
	<br />
// append buffB to buffA, use temp buffAB<br />
int n_AB = n_A + n_B;<br />
char* p_buffAB = new char[n_AB];<br />
	<br />
// cpy<br />
memcpy(p_buffAB, p_buffA, n_A); // copy buffA to buffAB<br />
memcpy(p_buffAB+n_A, p_buffB, n_B); // copy buffB to buffAB<br />
<br />
// buffA and buffB are no longer neaded -> delete<br />
delete [] p_buffA;<br />
delete [] p_buffB;<br />
<br />
// set buffA to buffAB<br />
p_buffA = p_buffAB;<br />
n_A = n_AB;<br />
<br />


Is this snipet ok?
Are there better ways to solve this issue?
GeneralRe: Newbie Question on C Pointers Pin
CPallini12-Jan-08 23:19
mveCPallini12-Jan-08 23:19 
GeneralRe: Newbie Question on C Pointers Pin
_NielsB12-Jan-08 23:45
_NielsB12-Jan-08 23:45 
Generalsearching web - automated Pin
Force Code12-Jan-08 10:34
Force Code12-Jan-08 10:34 
GeneralRe: searching web - automated Pin
Force Code12-Jan-08 10:46
Force Code12-Jan-08 10:46 
GeneralSwitching off hibernation [modified] Pin
tibiz12-Jan-08 8:33
tibiz12-Jan-08 8:33 
GeneralRe: Switching off hibernation Pin
David Crow12-Jan-08 9:44
David Crow12-Jan-08 9:44 
GeneralRe: Switching off hibernation Pin
tibiz12-Jan-08 9:47
tibiz12-Jan-08 9:47 
GeneralRe: Switching off hibernation Pin
David Crow12-Jan-08 10:11
David Crow12-Jan-08 10:11 
GeneralOk, let's have a Working code Pin
tibiz12-Jan-08 11:10
tibiz12-Jan-08 11:10 
GeneralRe: Switching off hibernation Pin
Blake Miller22-Jan-08 11:44
Blake Miller22-Jan-08 11:44 
Generalcontext menu cause flicking Pin
followait12-Jan-08 5:51
followait12-Jan-08 5:51 
QuestionRe: context menu cause flicking Pin
Mark Salsbery12-Jan-08 7:34
Mark Salsbery12-Jan-08 7:34 
GeneralRe: context menu cause flicking [modified] Pin
followait12-Jan-08 15:19
followait12-Jan-08 15:19 
QuestionRe: context menu cause flicking Pin
Mark Salsbery14-Jan-08 6:15
Mark Salsbery14-Jan-08 6:15 
Questiondifference between stack & heap Pin
raaf12-Jan-08 4:57
raaf12-Jan-08 4:57 
GeneralRe: difference between stack & heap Pin
CPallini12-Jan-08 5:44
mveCPallini12-Jan-08 5:44 
GeneralRe: difference between stack & heap Pin
raaf12-Jan-08 16:13
raaf12-Jan-08 16:13 

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.