Category : debugging

In C++11 I have a problematic line, when it’s commented my programs runs perfect. when I uncomment it it causes tons of errors. My line is: jobs.insert(std::lower_bound(jobs.begin(), jobs.end(), job), job); In the following function: void JobsList::addJob(Command *cmd, bool isStopped) { JobEntry tmp{}; tmp.pid = 0; //getLastJob(&tmp.jid); ++tmp.jid; tmp.stopped = isStopped; tmp.cmd = cmd->cmd; time(&tmp.in_time); for ..

Read more

I have a code in C++ that is called from a Python file. In order to look at the code and debug it, I use VS Code. I follow the instructions in https://nadiah.org/2020/03/01/example-debug-mixed-python-c-in-visual-studio-code/ However, I stuck in Step5 because when I try to attach GDB to Python, the terminal writes: Python Exception <class ‘ImportError’> This ..

Read more

I am trying to create an iterator to iterate over a map of type map<int, set> and print out the elements. This is what I have tried so far. I cannot seem to find the bug. It must be something simple. #include <iostream> #include <vector> #include <cstdlib> #include <string> #include <map> #include <set> #include <utility> ..

Read more

I’ve been working on this problem: https://www.hackerrank.com/challenges/insert-a-node-at-the-tail-of-a-linked-list/copy-from/208282883 I wrote the following code: SinglyLinkedListNode* insertNodeAtTail(SinglyLinkedListNode* head, int data) { SinglyLinkedListNode* temp=head; if (temp!=NULL){ while (temp->next!=NULL){ temp=temp->next; } SinglyLinkedListNode newNode(data); temp->next=&newNode; } return head; } However, I am not getting any output on stdout. Can someon tell what’s the issue with my code? PS: Please don’ t ..

Read more