0

Segmentation error: CS50 recover

My code: https://code.sololearn.com/ca200A167A25 copying the block of BYTES and writing to another new file calle NewImage after finding a block containing jpegs What problem are you having? Describe the problem in detail. If appropriate, include any error messages, screenshots, or small snippets of code to describe the issue. (Keeping in mind the course's policy on academic honesty, do not share code that may contain spoilers or solutions): I have used malloc to allocate memory for writing the file names and a bool to carry out the statements. I read through each chunk of BYTES reading through and writing it to the NewImage file that I have created and ending the loop when it reaches the end of the file being read. The code compiles all okay but I get a segmentation error. My part of the code that does these are as follows: **At the end, I free the memory to avoid any segmentation errors too A detailed walkthrough of the program is as follow: https://cs50.harvard.edu/x/2021/psets/4/recover/#:~:text=rm%20recover.zip

19th Apr 2021, 8:20 AM
Raiyan Rabbani
Raiyan Rabbani - avatar
1 Antwort
0
You know, if you want to use the bytes instead, you should set the fopen argument to "rb" for read binary, and then "wb" for write binary. I hope this helps!
1st May 2021, 3:24 PM
bernborgess
bernborgess - avatar