I want to delete all duplicates from a linked list. I know there is an exact program on GeeksForGeeks which is very similar to mine and I could use that, but I want to understand why mine is not working. Code: class Node {     public:         int data;         Node *next;   };  void removeDuplicatesAlpha(Node* start) {     Node* ptr1 = start;     Node* ptr2 = NULL;     Node* dup = NULL;     int i = 0;      /* Pick elements one by one */     while (ptr1 != NULL &amp;&amp; ptr1-&gt;next != NULL)     {         ptr2 = ptr1-&gt;next;         //0 1 2 3 4         /* Compare the picked element with rest            of the elements */         while (ptr2 != NULL &amp;&amp; ptr2-&gt;next != NULL)         {             cout &lt;&lt; i;             i++;              /* If duplicate then delete it */             if (ptr1-&gt;data == ptr2-&gt;data)             {                 /* sequence of steps is important here */                 dup = ptr2;                 ptr2 = ptr2-&gt;next;                 delete(dup);             }             else /* This is tricky */                 ptr2 = ptr2-&gt;next;         }         ptr1 = ptr1-&gt;next;     } }  int main() {     Node* head = NULL;      push(&amp;head, 3);     push(&amp;head, 3);     push(&amp;head, 20);     push(&amp;head, 14);     push(&amp;head, 9);     push(&amp;head, 20);     push(&amp;head, 20);      printList(head);      //removeDuplicates(head);     removeDuplicatesAlpha(head);      printList(head);      deleteList(&amp;head);      return 0; }  The last i printed is 4. This is the error: Exception thrown: read access violation. ptr2 was 0xDDDDDDDD. I'm so sorry if this is a dumb question but I just started working with Data Structures in C++.
I know that the compiler will sometimes initialize memory with certain patterns such as 0xCD and 0xDD.  What I want to know is when and why this happens.  When  Is this specific to the compiler used?  Do malloc/new and free/delete work in the same way with regard to this?  Is it platform specific?  Will it occur on other operating systems, such as Linux or VxWorks?  Why  My understanding is this only occurs in Win32 debug configuration, and it is used to detect memory overruns and to help the compiler catch exceptions.  Can you give any practical examples as to how this initialization is useful?  I remember reading something (maybe in Code Complete 2) saying that it is good to initialize memory to a known pattern when allocating it, and certain patterns will trigger interrupts in Win32 which will result in exceptions showing in the debugger.  How portable is this?
Can a lingering injury that requires "magical healing of 6th level or higher" be healed by an upcast lower-level spell? The  table in the DMG (p. 272) contains some wounds that can only be fixed by powerful healing magic, for instance:     Horrible Scar. You are disfigured to the extent that the wound cannot be easily concealed. You have disadvantage on Charisma (Persuasion) checks and advantage on Charisma (Intimidation) checks. Magical healing of 6th level or higher, such as heal and regenerate, removes the injury.   Can the necessary magical healing described here be a lower-level spell (such as cure wounds) that is upcast to 6th level? Or must it be a healing spell that is already 6th level or above before upcasting? Proof for triangle inequality for vectors Generally,the length of the sum of two vectors is not equal to the sum of their lengths. To see this consider the vectors $u$ and $v$ as shown below.  By considering $u$ and $v$ as two sides of a triangle, we can see that the lengths of the third side is $\| u + v \|$ and we have $\| u + v \| \leq \|u\| + \|v\|$.  Under what circumstance equality occurs and how can one prove that? Why can we flag/vote a question on Meta as duplicate of another question which has no accepted/upvoted answers? When we flag/vote-to-close a question as a duplicate on Stack Overflow, and that potential duplicate doesn't have any upvoted or accepted answers, we are alerted that we can't use that question as a duplicate and can't continue. This same check does however not seem to apply to Meta questions. Why not? Is is possible that a software issue could be causing spotty USB-C connections on 2017 MacBook Pro? I have a 2017 MacBook Pro. It has 2 USB-C ports on the left side and I use an Aukey hub to provide more ports (4 USB, 1 HDMI, 1 USB-C) and always to connect two monitors.   I connect one monitor through the hub with the HDMI port and another directly to the MBP with a USB-C adapter. Sometimes when I connect the hub to the Mac and the 2nd monitor to the Mac, it works as it should with no problem...but more than half the time I have to connect, disconnect, jiggle, jangle, switch ports, reconnect HDMI, etc. and hopefully they will both work. OFTEN, I can only get one monitor to fire up.  Is there any kind of software fix or reset that might solve this issue? Any other thoughts welcome. Thanks. , I shouldn't need to vote down or flag the answer, because the question itself is a dog.      Users should be allowed to also enable the "I'm done" button by down voting, close voting or flagging the question rather than directly taking action on the answer.    Currently, I have to click on the question's title, close or down vote it in the new tab, then go back to the review page, and click "Not sure" to continue on my adventure. How do I compare strings in Java? Why does the co-efficent of kinetic friction of a block on an inclined plane not change when you increase the angle of the plane? Did not get notification about new privilege On equations $m^2+1=5^n$ I read on  that Ubuntu will no longer use the familiar file size units we all know by now (kB, MB, GB, TB) and switch to a different IEC standard (KiB, MiB, GiB, TiB). If this is true, I would like to know what's the reasoning behind this change, and the impact (if any) this change has, especially with multiplatform applications or applications run with Wine. Can I travel to France with Fiktionsbescheinigung (Fiction Certificate) of Germany Gosper's unusual formula connecting $e$ and $\pi$ We've just been learning about complex numbers in class, and I don't really see why they're called numbers.  Originally, a number used to be a means of counting (natural numbers).  Then we extend these numbers to instances of owing other people money for instance (integers).  After that, we consider fractions when we need to split things like 2 pizzas between three people.  We then (skipping the algebraic numbers for the purposes of practicality), we use the real numbers to describe any length; e.g. the length of a diagonal of a unit square.  But this is when our original definition of a number fails to make sense- when we consider complex numbers, which brings me to my main question: what is a rigorous definition of 'number'?  Wikipedia claims that "A number is a mathematical object used to count, label, and measure", but this definition fails to make sense after we extend $\mathbb{R}$.     Does anyone know of any definition of number that can be generalised to complex numbers as well (and even higher order number systems like the quaternions)? Bad substitution: no closing "`" in a heredoc / EOF I'd like to print a man style usage message to describe a shell function like this output man find:  NAME        find - search for files in a directory hierarchy  SYNOPSIS        find [-H] [-L] [-P] [-D debugopts] [-Olevel] [starting-point...] [expression]  DESCRIPTION        This  manual  page  documents the GNU version of find.  GNU find searches the directory tree rooted at each        given starting-point by evaluating the given expression from left to  right,  according  to  the  rules  of        precedence  (see section OPERATORS), until the outcome is known (the left hand side is false for and opera‐        tions, true for or), at which point find moves on to the next file name.  If no  starting-point  is  speci‐        fied, `.' is assumed.  OPTIONS   I am facing an error message on the ` character. Following simple script shows the error:  ~$ cat &lt;&lt;EOF `.' EOF  bash: bad substitution: no closing "`" in `.'   I though heredoc was a cool way to echo strings by pasting them without having to escape its content such a quotes, etc... I assume I was wrong :/  Can someone explain this behavior please? Can heredoc accept ` character?  Edit 2: I accepted the answer of quoted here-document  &lt;&lt;'END_HELP', but I finally won't use it for this kind of complete manual output as  does   Edit 1: (For future reads) the limit with using quoted here-document is that is prevents to use tput in the here-document. To do so, I did the following:   unquoted here-document, for tput commands to be executed prevent the "bad substitution" error by escaping the backtick instead use tput within the  here-document   Example:  normal=$( tput sgr0 ) ; bold=$(tput bold) ;  cat &lt;&lt;END_HELP # here-document not quoted ${bold}NAME${normal}        find - search for files in a directory hierarchy  ${bold}SYNOPSIS${normal}        find [-H] [-L] [-P] [-D debugopts] [-Olevel] [starting-point...] [expression]  ${bold}DESCRIPTION${normal}        This  manual  page  documents the GNU version of find.  GNU find searches the directory tree rooted at each        given starting-point by evaluating the given expression from left to  right,  according  to  the  rules  of        precedence  (see section OPERATORS), until the outcome is known (the left hand side is false for and opera‐        tions, true for or), at which point find moves on to the next file name.  If no  starting-point  is  speci‐        fied, \`.' is assumed. END_HELP  unset normal ; unset bold ;   Here, note the escaped backtick that was source of error:  \`.' How is Gauss' Law (integral form) arrived at from Coulomb's Law, and how is the differential form arrived at from that? How can I fix/repair a corrupted PDF file? I believe there's a way to find the kth largest element in an unsorted array of length n in O(n).  Or perhaps it's "expected" O(n) or something.  How can we do this? Is there an easy way to limit user bandwidth usage? Comment font sizes are inconsistent on Android An issue similar to that described in  and likely to be related.  The comments for a question may vary in size:         Chrome for Android on Nexus 7 running 4.2.2 Jelly Bean. This also occurs on Firefox for Android: Using C# and WPF under .NET (rather than  or console), what is the correct way to create an application that can only be run as a single instance?  I know it has something to do with some mythical thing called a mutex, rarely can I find someone that bothers to stop and explain what one of these are.  The code needs to also inform the already-running instance that the user tried to start a second one, and maybe also pass any command-line arguments if any existed.