Hot answers tagged

19

You definitely need to store it in an array. However, think about the size each element in that array should have. An int usually has 4 bytes. What you want is to look for jpg signatures, which are 4 bytes at the beginning of each 512 byte block potentially. In order to store these 4 individual bytes correctly, you need a buffer of a type like this: BYTE ...


5

char would store the ASCII codes for the hexadecimal digits Well, not really! If you do something like unsigned char c = 0xff; // hex this won't store the ASCII value of 255(dec) because 255(dec) is not actually a char (like 'A' or '9'). It's an integer value and so are ASCII values (i.e., they're also integers). The thing is that variables of the ...


3

check50 is extremely literal in the way it checks your results. The results need to match it's expected answers exactly, any small difference will result in a fail. Fortunately the error report is often just as specific about the error. For example, the error report displays: Checking for file 000.jpg. ... but received no such file! Looking at the ...


2

The problem is that you are not printing using the same format in gdb and with the xxd command. xxd outputs hexadecimal and gdb outputs in decimal. To print in the same format with both programs a solution can be this. In the command line type: xxd -g 1 -l 4 card.raw Notice that -g 1 separetes the output of xxd in hexadecimals of one byte width, and the ...


2

Your code is fixable with 3 adjustments. The biggest problem is that your "tracker variable" (t) for your buffer gets reset to 0 for every pixel of the infile, rather than for every line. In other words, each scaled pixel is recopied into the first n spots of buffer. Fix this by moving int t = 0 outside by one for loop. Change the variable t that appears ...


1

an int is 4 bytes an unsigned char is 1 byte so buffer[3] in char is the 4th byte but in int it is the 13-16 bytes. so when using int you are not actually checking the first 4 bytes, but the first 16.


1

You're trying to put strings into byte/unsigned char/char arrays. Quotation marks denote a string. Since the values you're trying to put in are in fact, numbers, you must not use quotation marks. Good luck with the problem set! If this answers your question, please consider clicking the check mark button for forum maintenance.


1

It has nothing to do with the malloc call itself. The problem lies in what you think you are checking. Look at the following: RGBTRIPLE* row = ... int sizeRow = sizeof(row); row is declared as a pointer. sizeRow contains the size of the pointer row, not the actual size of the space allocated by the malloc that row points at. A good analogy is this: My ...


1

I see two issues immediately. First, you have a problem with your output padding. Hint: compare the calculation of your input padding to your output padding. Second, your program depends on being able to both read and write to the output file, but you have only opened it for read. Suggest you review the specs for fopen(). There's a third problem, maybe ...


1

The problem is not with the argv only but with every input from the user, that is not checked. For example say you define a string that will hold 10 characters (let's call it buffer). Then you ask the user to give you a string, but instead of giving you a string with 9 characters at most (plus the '\0') he gives you a string that is 100 characters long. Your ...


1

Your do while loop only runs 1 iteration. Check the condition.


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