Questions tagged [file-pointer]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
15 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 ...
user avatar
0 votes
1 answer
48 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 ...
user avatar
0 votes
1 answer
57 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 ...
user avatar
0 votes
1 answer
37 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 ...
user avatar
0 votes
1 answer
135 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 ...
user avatar
0 votes
1 answer
24 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 ...
user avatar
0 votes
1 answer
17 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, ...
user avatar
0 votes
2 answers
59 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 ...
user avatar
0 votes
1 answer
14 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 ...
user avatar
0 votes
1 answer
71 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 ...
user avatar
0 votes
1 answer
280 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 ...
user avatar
0 votes
1 answer
38 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 ...
user avatar
  • 3
0 votes
1 answer
429 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 ...
user avatar
  • 29
0 votes
1 answer
87 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 ...
user avatar
0 votes
1 answer
85 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 ...
user avatar
  • 3
0 votes
1 answer
78 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?
user avatar
0 votes
1 answer
48 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 ...
user avatar