|
Harry is "renowned"? Prolific YouTube creator, maybe, but not renowned.
A 125 video series on "How to become a job ready programmer in 3 months"? BWAHAHAHAHA! That's bullshit, and everybody in this field knows it. He's got a sh*t-ton of self-promotion marketing, but that doesn't mean he can teach.
modified 30-Aug-23 9:59am.
|
|
|
|
|
Dave Kreskowiak wrote: that doesn't mean he can teach
Or even write code, from the sounds of it.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Quote: How is that possible sir! Second code is written by a renowned youtuber 'code_with_harry'. I know. But here is renowed expert CPallini .
If you run Harry's code using Valgrind, then you get (something similar to)
==3144== LEAK SUMMARY:
==3144== definitely lost: 64 bytes in 4 blocks
==3144== indirectly lost: 0 bytes in 0 blocks
==3144== possibly lost: 0 bytes in 0 blocks
==3144== still reachable: 0 bytes in 0 blocks
==3144== suppressed: 0 bytes in 0 blocks
==3144==
==3144== For lists of detected and suppressed errors, rerun with: -s
==3144== ERROR SUMMARY: 4 errors from 4 contexts (suppressed: 0 from 0)
On the other hand, if you run the following, alternative code
#include <stdio.h>
#include <stdlib.h>
struct Node
{
int val;
struct Node * next;
};
void traversal(const struct Node * p)
{
printf("------------\n");
while (p)
{
printf("%d ",p->val);
p = p->next;
}
printf("\n------------\n");
}
struct Node * enqueue(struct Node *p, int val)
{
struct Node * prev = NULL;
while (p)
{
prev = p;
p = p->next;
}
p = malloc(sizeof(struct Node ));
if ( p )
{
p->val = val;
p->next = NULL;
if ( prev )
prev->next = p;
}
return p;
}
int dequeue(struct Node ** pp)
{
int val = -1;
struct Node * p = *pp;
if ( p )
{
val = p->val;
*pp = p->next;
free(p);
}
return val;
}
int main()
{
struct Node * ph = enqueue(NULL, 11);
enqueue(ph, 22);
enqueue(ph, 33);
enqueue(ph, 44);
traversal(ph);
dequeue(&ph);
dequeue(&ph);
traversal(ph);
dequeue(&ph);
dequeue(&ph);
return 0;
}
then Valgrind is somewhat happier:
==3153== HEAP SUMMARY:
==3153== in use at exit: 0 bytes in 0 blocks
==3153== total heap usage: 5 allocs, 5 frees, 1,088 bytes allocated
==3153==
==3153== All heap blocks were freed -- no leaks are possible
==3153==
==3153== For lists of detected and suppressed errors, rerun with: -s
==3153== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
|
|
Thanks for replying sir
The problem is solved
I'll let you know If encountered any other
|
|
|
|
|
The error message is clear: at the point the compiler encounters sizeof(struct Node) (or sizeof(nd) , or whatever...) it doesn't know the size, because the complete declaration of struct Node is missing.
You could post the relevant code, in order to get better help.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
Still here
|
|
|
|
|
It's been a while...
Nice to see you again.
How do you do?
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
Thanks sir it helped me alot
|
|
|
|
|
You are welcome.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
in visual studio c++ / x64:
what are way safest to convert from:
1.INT_PTR to int?
2.LRESULT to BOOL?
3.LRESULT to int?
|
|
|
|
|
|
Hi,
If you want to detect overflows, underflows, truncation. The Shell team provided the intsafe.h header.
wizQ wrote: 1.INT_PTR to int? The IntPtrToInt function will at least warn you if the pointer was truncated.
CPallini gave great advice, there really isn't a "safe" conversion. But you can at least detect overflows and underflows.
|
|
|
|
|
can one change int to LRESULT?.
change from
int c = ...
to
LRESULT c = ...
also change from
void func(int p,..
to
void func(LRESULT p,...
|
|
|
|
|
The question is, why would you want to do such a thing? The LRESULT type has a specific meaning and purpose, which is not the same as an int , or any other basic, type.
|
|
|
|
|
Hi,
Got two items to ask. First, is there a library available for c++ mfc that can write results to PDF?. libHARU is deoendent on zlib , libpng, etc. Like to try something more straight forward and free. secondly, is there a possibility to save a CDialog to PDF file?.
|
|
|
|
|
You could just print what you want using Microsoft Print to PDF printer.
|
|
|
|
|
When I googled certainly seem to suggest that.
"C++" pdf libary
Not free (I don't think) but years ago Crystal Reports had an API and among many outputs possible was PDF.
|
|
|
|
|
|
|
I have noted those discussion before, no clue..
|
|
|
|
|
Then perhaps you'll describe how you are doing the "dragging" anw how and in what class you are handling this notification...
|
|
|
|
|
Click the left button, hold on it and move the mouse to somewhere else, no any message receive... My codes as below:
<pre lang="C++"> BOOL CListCtrlEx::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT*
pResult)
{
LPNMLISTVIEW pnmv = (LPNMLISTVIEW)lParam;
switch(pnmv->hdr.code){
case LVN_MARQUEEBEGIN:
; // Deal with some case here.
break;
}
return CListCtrl::OnNotify(wParam, lParam, pResult);
}
This method is trigged only when move mouse into the dialog which contains CListCtrlEx object, message type is TTN_GETDISPINFOW.
|
|
|
|
|
I added the message handler for LVN_MARQUEEBEGIN in my CListCtrl derived class:
BEGIN_MESSAGE_MAP(CListOptionsCtrl, CListCtrl)
ON_NOTIFY_REFLECT(LVN_MARQUEEBEGIN, &CListOptionsCtrl::OnLvnMarqueeBegin)
...
void CListOptionsCtrl::OnLvnMarqueeBegin(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
*pResult = 0;
}
and it does work.
|
|
|
|