Questions tagged [file-pointer]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
94 views

reverse .wav file not working correctly

I tried running this code to reverse the .wav audio file, but it does not work as required. Can someone explain what's wrong? // create array of size (size) to store blocks BYTE buffer[size]; // ...
Ahmed ElToukhy's user avatar
0 votes
0 answers
17 views

Segmentation error in Recover Pset - any clues? A bit stumped

#include <stdlib.h> #include <string.h> #include <unistd.h> #include "check_arguments.h" #include "jpeg_file_structs_and_operations.h" #include <stdio.h> ...
BaaBaa's user avatar
  • 1
1 vote
0 answers
97 views

Lab 4 not altering output file - using solution word for word

I have looked at all the solutions here on the exchange. I have two issues. Firstly: const int HEADER_SIZE = 44; This does not work for me in the context of initializing a header array. I either have ...
madmonkey's user avatar
0 votes
1 answer
166 views

(PSET 4 - Recover) Why is first recovered image blank?

I am on problem set 4 recover and I have nearly completed it. I have written my code and it compiles but when I run it on the card.raw file it appears to recover all the 50 photos except the 1st one ...
Dre Johnson's user avatar
0 votes
1 answer
99 views

pset4 - Recover passed check50, but want to understand the logic on fwrite or file-pointer

Below are my code for pset4 - Recover, it passed the check50, but I am trying to understand the logic on a particular process of fwrite or file-pointer. In short, my question is how does line 74 know ...
user14494384's user avatar
0 votes
1 answer
45 views

Why does `size` = `0` occur?

I've been trying PSet4's Recover. I've been trying to obtain the size of the entered file (card.raw) but unfortunately size gives and output of 0. Here's the code that I've made to find the file's ...
MelPradeep's user avatar
0 votes
1 answer
191 views

Pset4 - recover - issue with file pointers

I'm working on recover and I think I'm nearly there but I can't resolve an issue with file pointers. When I'm compiling I'm getting two errors both say error: use of undeclared identifier 'ptr'. I ...
Wh0am3ye's user avatar
0 votes
1 answer
28 views

Understanding the contents of the raw file

I'm playing around with file pointers in preparation for the Recover Problem. I'm trying to understand something here. I can't actually open up the raw file to read on my IDE. And neither can I read ...
echorashmi's user avatar
0 votes
1 answer
23 views

Querry regarding maintainence and usage of files in c

So, csv files are used to store data and so does .txt files. I just want to know how do we manage a large text file. For example, if i have a file which contains all the info about school students, ...
Musical_Ant's user avatar
0 votes
2 answers
60 views

Can't write jpegs in recover, segmentation fault

here's the code i wrote: #include <stdio.h> #include <stdint.h> #include <stdlib.h> typedef uint8_t BYTE; //take command line argument from the user for the file name int main(int ...
Musical_Ant's user avatar
0 votes
1 answer
17 views

writting a function to display a file

in the week 4 shorts, it was told how we can write cat command from linux in c: i Wrote the following code: #include <stdio.h> include void Print_File(FILE *f) { char s = fgetc(f); while (s ...
Musical_Ant's user avatar
0 votes
1 answer
75 views

pset4 recover incorrectly generate images

I need your help with pset4 recover, as image does not recover correctly. And I would like to have more understanding on how file pointer works. Below is what I have written which generate no correct ...
Pedarun's user avatar
0 votes
1 answer
546 views

What does a pointer to a file really represent?

I have a question regarding file pointers (i.e FILE *). I am having a hard time understanding conceptually what this represents in terms of its memory. When the concept of files was introduced in ...
Bilal Junaidy's user avatar
0 votes
1 answer
39 views

pset4 resize: setting bfSize and biSizeImage hexadecimal values

I'm having difficulty setting the bfSize and biSizeImage header values. I should have the correct formulas for both values, however when I write either value to the output file I lose the leftmost ...
corvid's user avatar
  • 3
0 votes
1 answer
478 views

The function fread

How does fread actually work? In pset4 recover, i did this while (fread(buffer,sizeof(BYTE)*512, 1, inptr) == 1) { //If signature of first 4 elements is jpeg, create new file and write that ...
Iberico's user avatar
  • 29
0 votes
1 answer
88 views

pset 4 resize.c algorithm problem

I can't figure out why my code wont work. Please help. My idea for solving the height problem was write one line of the image move the file cursor to the beginning of the newly written line read in ...
Gupy Fish's user avatar
0 votes
1 answer
92 views

pset4 Recover Cant figure out why jpeg file pointer gets reset to NULL.

Using Error messages and gdb I figured out why I wasnt getting segfaults- img pointer - to the current jpeg file gets set to NULL. Are my loops all wrong? Im getting myself pretty confused. Code ...
osiris's user avatar
  • 3
0 votes
1 answer
84 views

Does IF condition increment file pointer?

Will: if(some_filepointer != NULL) { // do this } increment the file pointer? does the evaluation move the pointer to the next character in the file because the if condition read from the file?
Gibb Johnson's user avatar
0 votes
1 answer
50 views

Do I need to initialize my variables to a default value?

When creating a file pointer should I initialize it to NULL or should I leave it uninitialized? I currently have FILE* img;. I think the better practice is to have FILE* img = NULL; so it it doesn't ...
user avatar
1 vote
1 answer
1k views

Correct use of fopen, fclose, file pointers

I found this problem while working on recover.c. My program recovers all the image files, check50 says everything's cool, but when I run Valgrind, it gives me a ton of errors. After some tests, I ...
Alejandro's user avatar