Hot answers tagged

3

@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 bmp.h: #include <stdint.h> /** * Common Data Types * * The data types in this section are essentially aliases for C/C++ * primitive data types. * ...


2

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, and 224 is outside that range. You can use unsigned char or BYTE instead, which ranges from 0 to 255.


2

It is very weird but I advice you to follow these steps: Use ALTER TABLE <table> ENABLE KEYS to make sure that your keys are active. If nothing's still working, use ALTER TABLE <table> DROP INDEX <key_name or if no key_name set, column_name>. This command erase your Index_type and will allow us to reassign the columns with a FULLTEXT ...


2

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 returns 0, but if true, it returns a non-zero number. The problem is that the numeric value of "TRUE" is not necessarily the same as the number that is returned by ...


1

Just like the function printf, the valid_triangle function has to be called from within main in order to execute and produce results.


1

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 complex numbers in C, but you'd only use it for applications specific to complex numbers. Also, if x and y were complex, x < y isn't defined in the standard ...


1

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 means that the first parameter must be an int, and the var name rank is used inside the function. This should not be confused with vars anywhere else, such as in ...


1

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 what is the program supposed to return? If you simply add a return false; statement at the end, problem solved. Side note: Best practice for a function that ...


1

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 <stdio.h> #include "jpg.h" #include <cs50.h> bool jpgCheck(BYTE data[], BYTE jpgSig[]); int main(void) { BYTE jpgSig[1] = { 0xff }; BYTE data[1]...


1

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 || data[3] != 0xe8 || data[3] != 0xe8 || data[3] != 0xe9 || data[3] != 0xea || data[3] != 0xeb || data[3] != 0xec || data[3] != 0xed || data[3] != 0xee || data[3]...


1

You seem to have made quite a few mistakes in your code. This is of course not unusual for someone who's just starting out, so let me point you in the right direction. You are reading the first reply into a string variable called s. Later on, you refer to it as hungry. Choose whichever you prefer and rename the other instance to the same. To assign a ...


1

if (isdigit('k')) 'k' refers to the character or letter k, note that atoi converts the character of the command line to an integer, surely you want to do if (isdigit(argv[1]) however this is not correct because argv [1] is a string, not a character, the best since my understanding is not used isdigit, is a pset too early to get into trouble with strings.I ...


1

Yes there is, a couple ways actually. These all work the same way: if ( !boolean ) do... if ( boolean == false ) do... if ( boolean ) not here.. else do... I hope this helps.


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