This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
memcpy(d, s, n)[n - 1] = 0; | |
memmove(d, s, n)[n - 1] = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gcc -dM -E - < /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <limits.h> | |
/* number of decimal digits an unsigned integer type can have at most, | |
* not including the terminating 0 byte of strings. | |
* One needs log_10(2) digits per bit, 28/93 is slightly above this value. | |
* If bits * 28 is not divisible by 93, the result is truncated and one byte | |
* short, hence add 1. | |
* | |
* E.g. one needs 32 * l(2)/l(10) ~ 9.6323 ~ 10 bytes for 32 bit unsigned int. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-gnu - Use GNU coding style. This is the default. | |
---------------------------------------------------------------------------------------------- | |
-nbad - Do not force blank lines after declarations. | |
-bap - Force blank lines after procedure bodies. | |
-nbc - Do not force newlines after commas in declarations. | |
-bbo - Prefer to break long lines before boolean operators. | |
-bl - Put braces on line after if, etc. | |
-bli2 - Indent braces 2 spaces. | |
-bls - Put braces on the line after struct declaration lines. | |
-ncdb - Do not put comment delimiters on blank lines. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Kernighan and Ritchie: The C Programming Language | |
Stephen Prata: C Primer Plus | |
Brian Hook: Write portable code | |
Andrew Koenig: C traps and pitfalls | |
Peter v d Linden: Expert C programming - Deep secrets | |
C Unleashed | |
Jon Bentley: Programming Pearls | |
Robert Sedgewick: Algorithms in C |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
valgrind --tool=callgrind --toggle-collect=function ./program |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
#include <stdio.h> | |
enum car { honda }; | |
enum number { ZERO, ONE }; | |
enum number function_returning_number(char const *keyword) { | |
if (!strcmp(keyword, "zero")) | |
return ZERO; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT array_to_string(a[array_upper(a, 1)-1:array_upper(a, 1)], '.') | |
FROM string_to_array('gist.github.com', '.') a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
psql -d 'linspector' <<EOF | |
DROP TABLE IF EXISTS symbols, "files"; | |
CREATE TABLE symbols ( | |
filename text NOT NULL, | |
flag "char" NOT NULL, | |
symbol text NOT NULL, | |
PRIMARY KEY (filename, flag, symbol) | |
); | |
COPY symbols (filename, flag, symbol) FROM stdin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH | |
manufacturers (name, headquarters) AS (VALUES | |
('BMW', 'Munich'), ('Toyota', 'Toyota'), ('Fiat', 'Turin') | |
), | |
models (manufacturer, name, year) AS (VALUES | |
('BMW', 'm4', 2000), ('BMW', 'm5', 2000), | |
('Toyota', 'corolla', 2000), ('Toyota', 'yaris', 2000), | |
('Fiat', 'panda', 2000), ('Fiat', 'uno', 2000) | |
), | |
products (manufacturer, model, color, quantity, pretax) AS (VALUES |
OlderNewer