This file contains hidden or 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
// If you try to read a 3-byte file for a 4-byte object, | |
// then you will read 0 objects and the file position indicator will be moved | |
// to the end of the file | |
// | |
// so you can reach end-of-file and possibly miss 1-3 bytes | |
// if you've been reading 4-byte objects | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> |
This file contains hidden or 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
// COMPILING: | |
// gcc -std=c99 -Wall --output uniquelines uniquelines.c | |
// USAGE: | |
// ./uniquelines path/to/file1 path/to/file2 | |
// DESCRIPTION: | |
// Prints a list of the lines in file1 that are not in file2 | |
// and a list of the lines in file2 that are not in file1 | |
// Within a file, lines are separated by a single-character `DELIMITER` |
This file contains hidden or 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
#lang racket/gui | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; File: ray-demo.rkt | |
; Author: Costava | |
; License: zlib license (see end of file) | |
; Written for Racket 7.7 | |
; Opens a window |
This file contains hidden or 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
#lang racket/gui | |
(define frame (new frame% [label "Slider"])) | |
(new slider% | |
[parent frame] | |
[label "Volume"] | |
[min-value 0] | |
[max-value 100]) |
This file contains hidden or 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
// Writes a solid color P3 .ppm file to stdout | |
// using the given width, height, and RGB color arguments | |
// Info on the .ppm file format: | |
// https://en.wikipedia.org/wiki/Netpbm#File_formats | |
// Compile: | |
// clang solidcolorppm.c --output solidcolorppm | |
// Run: | |
// ./solidcolorppm <width> <height> <r> <g> <b> |
This file contains hidden or 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 -std=c99 -Wall --output cwrap cwrap.c && ./cwrap | |
#include <stdint.h> | |
#include <stdio.h> | |
int main(void) | |
{ | |
uint8_t val = 255; | |
val += 1; | |
printf("val: %d\n", val);// val: 0 |
This file contains hidden or 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
// The program reads stdin, counts the number of non-whitespace characters, and | |
// then prints the count to stdout | |
// UTF-8 encoding is expected | |
// If a non-ASCII character is found, the program prints to stderr and exits, | |
// but the program should be easy to extend to properly support UTF-8 | |
// COMPILING: | |
// gcc -std=c99 -Wall --output countnonwhitespace countnonwhitespace.c | |
// USAGE: |
This file contains hidden or 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
// Sort of a benchmark --- if touching every pixel every frame, | |
// a real program should not hope to get a higher frames per second | |
// than this simple demo. | |
// | |
// Single process and thread | |
// Uses SDL_Surface (none of SDL_Texture) | |
#include <stdbool.h> | |
#include <stdio.h> | |
#include <stdint.h> |
This file contains hidden or 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
// If a texture has format SDL_PIXELFORMAT_ABGR8888, | |
// then the red component is the first byte in the pixels array of the texture | |
// Tested on a little-endian (x86) system | |
// Would the red component also come first in the array on a big-endian system? | |
// | |
// Tested with SDL2 version 2.0.12 | |
#include <stdbool.h> | |
#include <stdio.h> | |
#include <stdint.h> |