3
votes
Accepted
Pset4 recover, comparing hex in if statements
@Blauelf is correct: you can't count on char to be an unsigned 8-bit int.
However, you can use a typedef to make certain that a BYTE is really a byte.
Look at these type definitions, borrowed from ...
2
votes
Pset4 recover, comparing hex in if statements
char can be signed or unsigned by default (and is 8-bit on every system I know, but that's not guaranteed by the specs).
On this system, char datatype is signed 8-bit int, ranging from -128 to 127, ...
2
votes
Accepted
What is the return value when isalpha() evaluates to true?
The problem is a lack of understanding of how many of these functions work. While you would think that isalpha() would return a bool, it doesn't. Instead, it returns a number. If it is false, it ...
1
vote
Accepted
Are boolean variables left uninitialized true or false?
There is no default value initialization guarantee of any kind in C.
I don't know where you learned the default value of booleans is false but I strongly question that information and disagree with it....
1
vote
Accepted
Do computers have to check if (false) the same way as whether (0 != 0), etc.?
Interesting question. The computer has to evaluate whatever is in the parentheses. The more complicated, the more it has to process.
If there is only a variable inside the parentheses, then the ...
1
vote
Accepted
Week 2 Lecture - Functions - Valid Triangle
Just like the function printf, the valid_triangle function has to be called from within main in order to execute and produce results.
1
vote
Else If Boolean Statements of Equality In the Case of Complex Numbers
That example doesn't say what data type x and y are, but generally you can assume that numerical variables are real numbers in programming, unless specified otherwise.
There is a way to work with ...
1
vote
Accepted
What's in the bool function parenthesis?
No such thing as a silly question. It just means that you haven't learned it yet. That's all. ;-)
This is a function "signature". It defines what is expected to be passed to the function. int rank ...
1
vote
Accepted
Pset3 is_rest does not compile right?
You get this error because it is possible to get to the end of the function without giving a value to return. Specifically, there's only the one return statement in the code. If value is not 0, then ...
1
vote
Pset4 recover.c compiles, but can't seem to print Jpgs at all
I tried to isolate some of the codes in modular form and created a file just to check this code. It seem to be the problem.
Did I declare the function within the if statement wrongly?
#include <...
1
vote
Accepted
Pset4 recover.c compiles, but can't seem to print Jpgs at all
Just to be crystal clear:
if (data[3] != 0xe0 || data[3] != 0xe0 || data[3] != 0xe1 || data[3] != 0xe2 || data[3] != 0xe3 || data[3] != 0xe4 || data[3] != 0xe5 || data[3] != 0xe6 || data[3] != 0xe7 ||...
Only top scored, non community-wiki answers of a minimum length are eligible