Questions tagged [file-io]

The tag has no usage guidance.

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

Struggling to understand file I/O

everyone. I'm just starting my journey in learning to code, starting with C. And for the past few months, I've been struggling to understand file I/O. More often than not, I don't get the output I'm ...
0
votes
1answer
43 views

I know that my recover is wrong, but I'm not sure what steps to take-

I 'm getting a segmentation fault for my recover code. I know that it's wrong, and I think that this boils down to me not really understanding how to apply pointers/file functions. Maybe you could ...
0
votes
1answer
61 views

Writing the .wav file fails with command-line notes

I have verified that my frequency(note) function returns the correct frequency as an int. However, when I attempt to write out using the "command-line note entry" testing scenario described (and yes ...
1
vote
2answers
32 views

What is the value read in the following code? if the open.txt file contains 1 to 10 numbers

#include <stdio.h> #include <stdint.h> #include <stdlib.h> typedef uint8_t BYTE; int main(void){ FILE* open = fopen("open.txt","r"); BYTE read; fread(&read,...
0
votes
1answer
90 views

ps4 resize, trouble scaling vertically

I've tried to do this by going back to the beginning of each scanline n times. I'm fairly sure that my problem lies in where I've tried to reposition to the beginning of the scanline, but I've changed ...
1
vote
1answer
2k views

pset4 resize, invalid or unsupported image format

I've looked up previous questions and seen people have also tended to change bfSize as well, but when I did this the image was still unsupported so I changed it back. As such nothing in ...
0
votes
1answer
62 views

Pset 6 'server.c' file size is 0, only for 'hello.php' - And maybe a check50 error?

Alright. I'm becoming crazy, so here I come. I finished the pset, and everything works. At least that's what check50 tells me. When I launch the server and try each file, they work, except for hello....
0
votes
1answer
35 views

Two sad faces remain on server.c

The two sad faces are the following: :( Requesting hello.php?name=Alice returns 200, text/html, and correct output and :( Requesting /test/ outputs /test/index.html Here's the code: bool load(FILE* ...
0
votes
1answer
298 views

Pset4, recover: Writing problem

Just finished recover.c, it worked and passed the check, happiness! Next I started my work on design, cut and recombine so many things. Now, I guess, my algorithm is efficient, but something went ...
0
votes
1answer
51 views

Segmentation fault in recover.c of pset4

Below is the function createjpg() I wrote for recover.c of pset4. I have written void createjpg (void) { // opening card.raw FILE* inptr = fopen("card.raw", "r"); // ensuring that the desired file ...
0
votes
1answer
63 views

PSET4 Recover: Storing Memory Addresses

I wanted to try a different approach to PSET4, but not sure if it's stupid or not. It seems to be 'kind of' working so hoping to get someone with more knowledge to help me understand whether this is a ...
0
votes
1answer
393 views

PSET4: fgets returns odd characters instead of what's in .raw

I know the first few lines of 'card.raw' are (by opening in a texteditor): bit.ly/18gECvy ˇÿˇ‡JFIFHHˇ€Cˇ€Cˇ¿Vˇƒ Currently all I want the app to do is print back what's in the .raw file, and then ...
0
votes
1answer
77 views

is the end of a word in a text file marked by a particular char?

given a text file containing multiple words like CS50, Add, work, etc. does each of these words end with '\n', or both, '\0' and '\n'?
1
vote
1answer
577 views

pset6 load: fread returns 0

So far, my server seems to be working correctly except when it comes to the step of loading a file into memory. I'm using fread to get the info. from file, and my goal is to store the number of bytes ...
0
votes
1answer
318 views

Recover.c outputting 50 jpegs of size 512 bytes only

So I've made progress and wrote what I have in here. My program outputs 50 jpegs of size 512 bytes. I know that may program writes only 512 bytes to a newly created jpeg but I don't know what should I ...
0
votes
1answer
240 views

Pset4 Resize Error

When I try to run the program, I get the message "file size limit exceeded." After looking over my code many times, I can't figure out what might be going wrong?? /** * copy.c * * Computer Science 50 ...
0
votes
1answer
58 views

Linked list doesn't print out the correct values (when using fopen)

When I run following program with a list of 5 words I keep getting an output of last last last last last opposed to last fourth third second first (ie the contents of the word list which I am ...
0
votes
1answer
74 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
40 views

problem using fscanf

In this program when I'm using "char* str" instead of char str[80] its printing null instead of strings. Why? #include<stdio.h> int main(){ char str[45]; FILE* dic = fopen("small", "...
0
votes
1answer
43 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 ...
2
votes
2answers
446 views

How are file data stored in an int buffer?

For example, in copy.c in pset4, how is 0x42 0x4d(ASCII for 'BM') stored in bfType which is of the type uint16_t? It can't be bfType = 0x424d because that is a completely different number. And of ...
1
vote
1answer
136 views

Why isn't a dereference operator used when doing File I/O in C

It might be a dumb question, but I've searched and couldn't find an answer. For example FILE *fp = fopen (argv\[1\], "w"); ... fputs (input, fp)[1]; The fp doesn't have a * in front of it. I ...
0
votes
1answer
84 views

Cant validate whether file being read is JPEG or not in recover

I cannot validate whether the file is JPEG or not with a help of the pattern. Thanks in advance. Here is my simple code: typedef uint8_t BYTE; int main(int argc, char* argv[]) { char* ...
0
votes
0answers
126 views

open file in binary mode, as opposed to text mode

On the http://www.cprogramming.com/tutorial/cfileio.html web page we can read <>. Well, an image file is actually not a text file. But in another stackexchange answer it is stated that a BMP file ...
0
votes
1answer
167 views

pset5 resize file io fread

Among the recommended reading list for this pset was this page (http://www.cprogramming.com/tutorial/cfileio.html), which indicates that when using fopen specifically for reading or writing in binary, ...