Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 10074
0 votes
Accepted

pset5, have a seg fault but valgrind reports no error

You are running out of stack memory in your recursive calls to unload. I suspect, based on this post, that you need a return after free (destroyer);
DinoCoderSaurus's user avatar
0 votes
Accepted

Recover.c problem

You are not verifying whether your freads were successful or not. See Week 4-> Shorts-> File I/0. Jason discusses this around the 8:15 mark. He's using fgets in the video, but the same advice applies …
DinoCoderSaurus's user avatar
1 vote
Accepted

PSet2 Vigenere Segmentation Fault Error

To clarify: the error /opt/sandbox50/bin/run.sh: line 31: 11290 .... is from check50, not from compile. It happens when check50 tests for "handles lack of argv[1]". That is because you do string k = a …
DinoCoderSaurus's user avatar
2 votes

How to copy a string in pset2? strcpy results in segfault

The main reason for the seg fault is this string titleized_string = "";. As soon as you "set" titleized_string to "something-in-quotes" it becomes a constant. You cannot strcpy into a constant (it ha …
DinoCoderSaurus's user avatar
1 vote
Accepted

This code is written as per video in CS50 week 4 but it is not working

You are always using the subscript 'i'. 'i' has the value 3 when the first loop is finished. You can either change the subscript names in the y loop and the x loop OR just use 'i' again to run those l …
DinoCoderSaurus's user avatar
0 votes
Accepted

Pset5 - Implementing Load function - Help with calloc

It might be sizeof here new_node -> children[c] = calloc(1, sizeof(new_node));. new_node is a pointer, sizeof a pointer is like 8. Probably a typo; look at the allocation of root earlier in the code. …
DinoCoderSaurus's user avatar
0 votes

Pset2 Vigenere Segmentation fault, have read prev answers but still stuck

Actually, it's the atoi function here int key = atoi(argv[1]);. Since vigenere takes a "word" as the argument, it cannot convert it to an "integer". From man atoi: .... atoi() does not detect er …
DinoCoderSaurus's user avatar
0 votes

Error in my cs50's unload function in pset5 - speller - trie

One potential segmentation error, not related to the valgrind results, is in the magic function. Apostrophe (') is ascii 39. It will not take the a == 96 branch and will return a negative number here …
DinoCoderSaurus's user avatar
0 votes
Accepted

PSet 2 Getting Segmentation Fault Error for Caesar

In C, anything between single quotes (ticks or ') is interpreted as a char. Anything between double quotes (") is interpreted as a string. These lines if (isalpha('s[i]')) and if (isupper ('s[i]')) a …
DinoCoderSaurus's user avatar
0 votes
Accepted

Seg fault in check function PSET5 Speller

You should be able to find the line that seg faults quite easily with debug50. Set a breakpoint at check. Create a small text file, one word will do. Then run debug50 ./speller small.txt small.txt. It …
DinoCoderSaurus's user avatar
1 vote

Pset3 counting sort - segmentation fault error

This would work if no element of the values array is greater than 5. Since counts is initialized to limit, it has 5 elements, indexes 0 through 4. What happens here counts[values[i]-1]++; if values[i] …
DinoCoderSaurus's user avatar
1 vote
Accepted

pset5 speller works in debug mode, throws segfault otherwise

The reason it does not give a seg fault under gdb is because of different memory usage than when it's run from the command line. The problem lies in the hash function. You might have started out with …
DinoCoderSaurus's user avatar
1 vote
Accepted

why pset5 works with small dictionary but with large dictionary gives munmap_chunk(): invali...

Problem is here char *word = malloc(sizeof(LENGTH + 1));. Specifically sizeof(LENGTH + 1). LENGTH + 1 returns an int. sizeof(an int) is 4 in the IDE. If you want to see what problems there are, and si …
DinoCoderSaurus's user avatar
1 vote
Accepted

Pset 5 speller: segmentation fault for large dictionary

From man fgets (emphasis added): ...reads in at most one less than size characters from stream and stores them into the buffer pointed to by s. Reading stops after an EOF or a newline. It's reading …
DinoCoderSaurus's user avatar
0 votes

Pset4 Recover Segmentation Error. Valgrind unable to find anything

debug50 may be a better tool at this point, so you can find where program is crashing. Assuming the first block is not a jpg signature, where does program control go when this if (buffer[0] == 0xff && …
DinoCoderSaurus's user avatar

15 30 50 per page