Hot answers tagged

5

I had the same problem. The only way I've been able to use the graphical interface is to run debug50 ./programname from the terminal. An alternative would be to use gdb from the terminal which there's a CS50 section on: https://www.youtube.com/watch?v=y5JmQItfFck


3

Declaring the array here int matrix[candidate_count]; allocates the memory for it. But it does not initialize the contents. At the end of the for loop, there is a good chance that matrix[m] has not been set to anything. The difference between the debug50 result and the program is result is because the contents of the assigned memory addresses is different.


3

CS50 has now released debug50 a more stable version than its predecessor. You can also manually use gdb through the command-line with; gdb OBJECT-FILE (where OBJECT-FILE is a vigenere.o, or just vigenere). Inside of which you can type r for run, n for next, c for continue, and b followed by a line number or function, such as b 50 (breaks line 50) or b foo (...


1

I had the same problem. What seems to be working for me is running debug50 ./programname from the terminal.


1

Google "cs50 gdb youtube" and you will find two helpful videos explaining how to use the debugger from the command line. It's much more reliable, and has the added benefit of being a tool that will always be available to you in the future even if you do not use the Cloud9 IDE for development. Basically, to debug myprog with a breakpoint at myfunc, passing ...


1

Google "cs50 gdb youtube" and you will find two helpful videos explaining how to use the debugger from the command line. It's much more reliable, and has the added benefit of being a tool that will always be available to you in the future even if you do not use the Cloud9 IDE for development. Basically, to debug myprog with a breakpoint at myfunc, passing ...


1

I forgot to answer my own question. Using dump() is better than using print statements


1

This will (hopefully) explain this specific problem in main and perhaps the overriding problem. The output buffer is not "flushed" until a new line (or explicit flush). The answer provided here explains it. If the added debugging printfs are "not executing" it could be for the same reason, since the first "\n" that is encountered would likely be after "...


1

Maybe try <vector.h> and <string.h>? Note the missing .h BTW, how is this related to CS50? I don't believe it's teaching c++


1

There are no other logs. If you cannot repro in your app, this will take a little more sleuthing. The trick would be to find the condition(s) that causes check50 to give TypeError. Since this viable_balance = cash - total_amount is the only subtraction in the buy function, it's a good place to start. The error is claiming that total_amount is a string. ...


1

The problem lies in this block of code: if (trav -> children[c - 97] == NULL) { trav -> children[c - 97] = calloc(1, sizeof(node)); } else { trav = trav -> children[c - 'a']; } Think about what's happening here. There are two cases - the next node exists or it doesn't exist. ...


1

Whenever an unexpected value, particularly 0, suddenly appears in the sorted list and the largest value disappears, look for code that goes beyond the end of the array. This is a somewhat common error. The code is going past the end of the array and picking up what it thinks is another element. Usually, this turns out to be 0, and gets sorted to the ...


1

DinoCoderSaurus is right, you should check any file pointer after fopen for being NULL (that's your current segfault, and use fopen (dictionary, "r");, not a hard-coded path). In theory, that's also true for malloc, to maybe exit gracefully instead of segfaulting. Doesn't always help, but you should still check it. malloc does not initialize the memory, so ...


1

Attention to detail. What happens if "dictionary/large.text" doesn't exist? (and in a standard installation, it doesn't!). Boom, seg fault. Don't forget to test for success. function takes dictionary as an argument, so don't open a "named" file.


1

To run GDB with arguments in the terminal, use the --args parameter. gdb --args name arg1 arg2 arg3 debug50 (the graphical debugger) is just GDB with a GUI. GDB was originally designed to be run through the terminal, and still is. It is much more flexible than any graphical debugger. Here's a complete reference guide for GDB: https://sourceware.org/gdb/...


1

Here's what I do. Use debug50 instead of the command line gdb. If you haven't used that before: Run update50 to be sure you are up to date (the IDE is on version 81 at the moment). Then, here's part of this year's class where Prof Malan explains how debug50 works. https://video.cs50.net/2016/fall/lectures/2?t=22m20s (if it doesn't go to that timestamp, ...


1

The old "debug" button has been removed in favor of a more stable version, the now revised debug50 requires you to run debug50 PROGRAMNAME [ARGUMENTS] in the terminal. Here's a link to the post posted by Malan in the /r/cs50 subreddit at reddit.


Only top voted, non community-wiki answers of a minimum length are eligible