Hot answers tagged

8 votes
Accepted

pset4 resize, invalid or unsupported image format

The immediate problem lies with your header structures. You have created bi_new and modified two of it's fields, but you forgot to copy the contents of bi to bi_new, so all of the unmodified fields ...
Cliff B's user avatar
  • 68.3k
3 votes
Accepted

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

Actually, the program is working exactly as designed. Unfortunately, it isn't what you think. ;-) If you run the program, it will essentially copy the input file to the output file. Along the way, ...
Cliff B's user avatar
  • 68.3k
2 votes
Accepted

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

There are several issues and areas for improvement here. First, there's this: FILE *f = fopen("argv[1]", "r"); By putting argv[1] in quotes, you're saying to treat whatever is in ...
Cliff B's user avatar
  • 68.3k
2 votes

Segmentation fault in recover.c of pset4

FILE* img = fopen(title, "w"); // SEGMENTATION FAULT OCCURRING REALLY HERE This is because char title [3] does not have enough space to store the title, change it to char title [8] for example
MARS's user avatar
  • 5,169
1 vote

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

The fread and fwrite functions are working fine, as expected, the problems are elsewhere, a somewhat more coherent way of writing your program will be the following: #include <stdio.h> #include ...
MARS's user avatar
  • 5,169
1 vote
Accepted

ps4 resize, trouble scaling vertically

Your you are very close to the solution. The most serious problem of this program is the padding: fseek(inptr, -(bi.biWidth + padding), SEEK_CUR); your value is not correct, but nearly. note that ...
MARS's user avatar
  • 5,169
1 vote

Two sad faces remain on server.c

Based on the fact that you only posted code that relates to query, you solved your indexes problem. Good on ya. I'll try to be the "human gdb" for the query code. But really, command line gdb is ...
DinoCoderSaurus's user avatar
1 vote
Accepted

Pset4, recover: Writing problem

The problem is that the code has a memory overwrite problem that is corrupting data while it's being processed. It's very subtle and easily missed. char title[7]; Since title is only 7 chars long, ...
Cliff B's user avatar
  • 68.3k
1 vote

PSET4 Recover: Storing Memory Addresses

I didn't to a thorough analysis, but I did see a few things and have some thoughts. First, the signature test will pass any value for the 4th byte. Because of the or clause, (s[3] <= (char)0xef || ...
Cliff B's user avatar
  • 68.3k
1 vote
Accepted

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

a text file is a stream of individual characters, not strings. the way you read/store a group of these chars, from the file, totally depends on you. for example, you may wanna read collectively or ...
kzidane's user avatar
  • 17.7k
1 vote

pset6 load: fread returns 0

From man fread (emphasis added): On success, fread() and fwrite() return the number of items read or written. This number equals the number of bytes transferred only when ...
DinoCoderSaurus's user avatar
1 vote
Accepted

Recover.c outputting 50 jpegs of size 512 bytes only

According to your code's logic, a new file will be opened and be written with 512 KB data each time it finds the specific header. Your program won't write any other 512 KB chunks to the file because ...
aquablitz11's user avatar
1 vote

Pset4 Resize Error

Can you say "typo = infinite loop" ? // replicate pixel n times to outfile for(int l = 0; l < n; i++) { fwrite(&triple, sizeof(RGBTRIPLE), 1,...
Cliff B's user avatar
  • 68.3k
1 vote
Accepted

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

I think the issue is that all of your nodes' word elements are pointing to the same chunk of memory. Let's take a look. In main() you ask for a new pointer with this line: char* word = malloc(...
Sam Gerber's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible