Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
2 answers
18 views

Getting segmenatation fault even though i freed memory

#include <stdio.h> #include <stdlib.h> #include <stdint.h> typedef uint8_t BYTE; int main(int argc, char *argv[]) { // Only allow 2 command line arguments if (argc != 2) ...
lukadeving's user avatar
0 votes
1 answer
35 views

pset4 speller trie segmentation fault

I am doing the trie version of speller in pset4 and keep getting a segmentation fault. I have run my code on short dictionaries and short text files and it seems to work just fine but when I try ...
Egill's user avatar
  • 3
0 votes
1 answer
154 views

PSET4 (Speller) malloc and calloc usage

After getting my code to work, i looked if there were any memory leaks using valgrind. It found no memory leaks, however it returned these two errors: ==7109== Conditional jump or move depends on ...
tomas-silveira's user avatar
0 votes
1 answer
115 views

PSET4 free on malloc in hash function

I'm trying to improve my hash function in Speller and I'm having trouble freeing allocated memmory. I'm getting * Error in `./speller': free(): invalid pointer: 0x0000000001a02252 * Aborted I know ...
Victor's user avatar
  • 1
0 votes
1 answer
77 views

PSET 4: Resize. Does not work with dynamic buffer, only static

I managed to make resize work using a static array to store a row of pixels for the outfile (rewrite method). However, my first attempt with a dynamic array doesn't work, and I don't understand why. ...
user3230142's user avatar
0 votes
1 answer
2k views

PSET4: free(): invalid next size (fast)

So as the title says, I'm trying to do the pset4 where I get this error when I try to execute the program. I've searched the forum and also Reddit, and I understood that I've some issue with the ...
Dement0's user avatar
  • 13
0 votes
1 answer
288 views

pset4 recover with malloc having a segmentation fault

I can't seem to find the reason of why I'm getting the segmentation fault in my code. The moment my code starts to write the bytes of buffer, I encounter the fault Any help is really appreciated. #...
Candaş Ünal's user avatar
0 votes
1 answer
49 views

What will happen if you assign a static value to a pointer in C?

In this example, what will it happen if I assign for example: pk = 6; Thanks!
gonzaloorsi's user avatar
0 votes
1 answer
804 views

pset4 recover.c - working with fread() and malloc()

I'm attempting recover.c and I'm interested in clearing up a few things about fread() and malloc(). I tried to sample the first few bytes of the card.raw file but I keep getting the same two errors: ...
Kyle's user avatar
  • 15
0 votes
1 answer
240 views

pset 4 recover - segmentation fault with malloc

I seem to be stuck on pset4 recover and would appreciate some help! I think I understand the idea of the problem set by now but I've done approached the problem a bit unconventionally and keep getting ...
Jeremy Chow's user avatar
0 votes
1 answer
605 views

pset4 resize: how to copy a row

Just spent 2 days for figuring out how fread(), fwrite() and fseek() works. I tried to use "Rewrite" method from Zamyla's video for vertycal resizing: - Remember pixels in array (first written row of ...
Semyon Pilyukov's user avatar
0 votes
2 answers
246 views

Segmentation fault in recover.c (pset4)

On checking with valgrind, I get main (recover.c:89) ==14182== Address 0x55022c8 is 0 bytes after a block of size 8 alloc'd There are 2 more problems with malloc again, while doing sprintf and ...
Vaibhav Kulshrestha's user avatar
0 votes
0 answers
143 views

pset4/resize | reading and writing a file simultaneously?

I'm trying to use "malloc" approach to the task. My algorithm is: draw a multiplied scanline into a new file fread this line, save itto a string, write it to the file factor-1 times do the same ...
Fed's user avatar
  • 3
0 votes
1 answer
212 views

pset 4 Recover creates 50 corrupted or mainly grey images

I wanted to try using malloc and a BUFFER structure of 512BYTES for this exercise with the intention of creating a file if the 4 signatures of a JPG are detected and fwriting the struct of 512B into ...
alo129's user avatar
  • 3
0 votes
1 answer
494 views

pset4 malloc() approach. Help with size of buffer

I'm having some trouble with the malloc function. I want to make a buffer the size of the new row I'm going to write in the resized file, and this is my approach. I must say that bi.biWidth is ...
Alejandro Aristizábal's user avatar
0 votes
1 answer
191 views

Want to make sure I understand struct, malloc, and pointers and how they relate to each other

Sort of related to PSET4 resize, but actually want to make sure I understand this in general. So at first I just declared a struct BITMAPINFOHEADER called "new_bi" and dealt with it while avoiding ...
CS50_on_the_go's user avatar
0 votes
1 answer
76 views

How can I avoid a Segmentation fault in my Recover.c

I have looked thoroughly through other solutions, but they tend to be specific to another person's code. I have also used Valgrind to try and isolate the problem, and considered that I may have to use ...
Andrew Gidney's user avatar
0 votes
1 answer
64 views

Pset4 Recover fails check, looks right and file sizes are right

struggling with the last piece of the puzzle for Recover. I'm pretty sure It's related to a memory leak of sorts, but I fail to understand how to resolve it. Here is my code: http://pastebin.com/...
Joshua Yourth's user avatar
0 votes
1 answer
480 views

fread not putting what I expect in buffer

for Pset4, recover, I'm trying to read 4 bytes from card.raw into a buffer. I''m testing the first 4 bytes of card.raw with what my buffer contains using gdb, and I'm not getting the same thing. I ...
Faith's user avatar
  • 22