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
288 views

problem with recover.c using malloc and fread

i tried to write a function that sample 4 bytes from card.raw file but i doesn't work because fread doesn't put any data into block buffer so i wrote this simple code and i found out that fgetc works ...
Antwan Samir's user avatar
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
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
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
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
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
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