In this thread we write one fact about ANY technology or programming language to teach each other. Also post infographics.
In C programming language, the #include preprocessor directive includes the header file contents to the source code file.
It does a copy-paste from headerfile.h to source.c before the compiler runs, hence it is preprocessing.#include <someheaderfile.h>
...
In C the function called "main" is special, the program starts from the first instruction in this function.
Example main function:int main(void)
{
/*first instruction to be executed goes here*/
return 0
}
The sequence of generating a program from C source code is as follows:
1. preprocessor (directives like #include etc.)
2. compiler (translates C source code to assembly)
3. assembler (translates assembly to machine code)
4. linker (embeds machine code in an executable file eg. ELF)
The knapsack problem is an example of NP-complete problems.
For any k items, each having it's own weight w we are looking for such a subset of these items, so that the sum of weights inside the subset is equal to some N. In the worst case, we must check each of the 2^k subsets. If it was possible to solve the problem in polynomial (not exponential) time, then we'd prove that P=NP and get a million $.
>>55097994
using the single line comment syntax//comment
or declaring the iteration counrer variable in a for loop likefor (int i = 0; i < 10; i++) {
;
}
are both invalid in ANSI C or C89
a lot of C programmers don't know this because most modern compilers default to C99
>>55098198
Ha! But I knew this. Anyway, it's cool that you wrote about it. I'm really pedantic about ANSI C in my simple programs.
On GNU/Linux OS one can easily see the USB devices by typing in the terminal emulator: lsusb
>>55098222
>I'm really pedantic about ANSI C in my simple programs.
me too, I always write a little buildscript to call the compiler with a bunch of options including -ansi so it will fail to compile if I break the C89 standard.
>>55097994
>>55098325
>>55098398
why the tease? dump them