Questions tagged [file-pointer]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
45 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 ...
0
votes
1answer
35 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 ...
0
votes
1answer
94 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 ...
0
votes
1answer
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 ...
0
votes
1answer
13 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, ...
0
votes
2answers
57 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 ...
0
votes
1answer
13 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 ...
0
votes
1answer
70 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 ...
0
votes
1answer
108 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 ...
0
votes
1answer
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 ...
0
votes
1answer
412 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 ...
0
votes
1answer
85 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 ...
0
votes
1answer
82 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 ...
0
votes
1answer
75 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?
0
votes
1answer
44 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 ...
1
vote
1answer
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 ...