Hot answers tagged

8 votes
Accepted

How do I share a variable between source files in C with extern?

From this really long answer: Using extern is only of relevance when the program you're building consists of multiple source files linked together, where some of the variables defined, for ...
user avatar
  • 17.4k
7 votes
Accepted

How to interpret biHeight data

That is because biHeight in this case is a negative number, and the representation in binary is made by the two's complement in this case, this can be a bit confusing but you can take a look at the ...
user avatar
  • 1,369
4 votes
Accepted

How do the headers in copy.c update on pset4?

In your example, bf and bi are pointers to two different structures that hold several variables each. These commands will actually write out the indicated full header structures out to the files. Let'...
user avatar
  • 63.5k
3 votes

How to interpret biHeight data

From MSDN, biHeight The height of the bitmap, in pixels. If biHeight is positive, the bitmap is a bottom-up DIB and its origin is the lower-left corner. If biHeight is negative, the bitmap is a ...
user avatar
  • 17.4k
2 votes
Accepted

resize cs50. I am updating headers correctly?

Your problem is with the new_bf.bfSize. It holds the size of the whole bmp file, not just the headers and the image as you imply, but also the offset from the beginning of the BITMAPFILEHEADER ...
user avatar
  • 7,326
1 vote
Accepted

Changing file header- Invalid or unsupported format

I'd like to see what came before this code. Before you did the freads to load the new headers, did you reset the file pointer to the beginning of the file? If not, then it isn't reading the headers. ...
user avatar
  • 63.5k
1 vote
Accepted

Why do we write #include "structs.h"?

This is not true, we can use structures without using that header file. It is possible that your source code specifically needs that file, but not in general. If we write: #include "structs.h" Means ...
user avatar
  • 5,172
1 vote
Accepted

Pset4 Resize Horizontal Not Working

I'm a little hesitant to offer any advice because I'm not so excellent at this stuff myself, but you're already making mistakes in your new header data calculations - that's certainly whats indicated ...
user avatar
1 vote
Accepted

How to get list of function signatures from header files

It is difficult to respond in a simple way, without going into great depths we can find very good documentation in man pages: We can find documentation of the standard head files by typing in the ...
user avatar
  • 5,172
1 vote
Accepted

Issue with creation of new header files in pset4

You'd have to copy the other fields from bi to bi_new. Easiest way is to initialize bi_new using BITMAPINFOHEADER bi_new = bi; which copies the whole structure, you'd still have to change the fields ...
user avatar
  • 20.7k
1 vote

Problem with outfile's header

Maybe you should initialize bf_resize and bi_resize to copies of bf and bi (they should be the same except for four size-related fields), using for example BITMAPFILEHEADER bf_resize = bf; ...
user avatar
  • 20.7k
1 vote
Accepted

Problem with header data in resize.c

You are correctly reading the BITMAPFILEHEADER and BITMAPINFOHEADER from the file. You are also correctly creating the new ones for the output file, and you correctly change the values you have to ...
user avatar
  • 7,326
1 vote

Problem with cs50.h header file!

I solved the cs50.h problem by updating my appliance. For updating open the terminal in the appliance and type-- update50 After the process is completed, cs50.h will work..
user avatar
1 vote
Accepted

pset7 two headers

You appear to be doing it in a wrong way. quote.php, sell.php, buy.php, etc are the controllers themselves. You probably should receive input using the forms, do all the work you need (e.g., ...
user avatar
  • 17.4k
1 vote

How do I share a variable between source files in C with extern?

the answer is wrong, please change it. see below for the correct file1.c from the really long answer: #include "file3.h" /* Declaration made available here */ #include "prog1.h" /* Function ...
user avatar
  • 110

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