Skip to content

Instantly share code, notes, and snippets.

Avatar

Marek Poláček Polda18

View GitHub Profile
@Polda18
Polda18 / recursive.c
Last active Dec 2, 2018
Recursive function example
View recursive.c
#include <stdio.h>
#include <stdlib.h>
int factorial(int n);
int main(int argc, char* argv[])
{
if(argc > 1)
{
int number;
@Polda18
Polda18 / os_enviro.h
Created Feb 7, 2018
Environment branching
View os_enviro.h
/****************************************
* OS environment branching
****************************************/
#ifndef __OS_ENVIRO_H__
#define __OS_ENVIRO_H__
#if defined(unix) || defined(__unix) || defined(__unix__)
#define UNIX
#elif defined(__APPLE__) || defined(__MACH__)
@Polda18
Polda18 / architectures.h
Created Feb 7, 2018
OS environment definitions
View architectures.h
/***********************************************
* Architecture environment branching of OS
* Basic structure
***********************************************/
#ifndef __ARCHITECTURES_H__
#define __ARCHITECTURES_H__
#if defined(i386) || defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(_X86_)
#define ENV32
@Polda18
Polda18 / flagbits.h
Last active Feb 7, 2018
Complete usage of integer flag bits: edit how you need
View flagbits.h
/*************************************************************************
* 32bit integer bitwise flags
* Complete definition - by Polda18
*************************************************************************
* You may rename flags as you wish, and use as many as you wish.
* If for some reason you need more than 32 bits, you can expand
* the definition by adding more 32 bits and a switch "L" like that:
* 0x0000000000000000L => That makes the literal long int
*************************************************************************/
@Polda18
Polda18 / ibsp_format_def.h
Last active Feb 7, 2018
Quake III Arena & Quake Live IBSP file format spec
View ibsp_format_def.h
// Source: http://www.mralligator.com/q3/
// Source: https://github.com/id-Software/GtkRadiant/blob/master/tools/quake3/q3map2/q3map2.h
#ifndef __IBSP_FORMAT_DEF_H__
#define __IBSP_FORMAT_DEF_H__
// Byte definition
typedef unsigned char ubyte;
// Vectors definition
@Polda18
Polda18 / login.cpp
Last active Feb 23, 2019
Hiding a user input
View login.cpp
// source: https://stackoverflow.com/questions/6899025/hide-user-input-on-password-prompt
#include <iostream>
#include <string>
#ifdef WIN32 // Windows
#include <windows.h>
#else // Unix = Linux / Mac OS
#include <termios.h>
#include <unistd.h>
@Polda18
Polda18 / bytes-representatives.c
Last active Jan 29, 2018
Bytes text representation with 0x00-0xff hexadecimal ASCII table
View bytes-representatives.c
#include <stdio.h>
#include <stdlib.h>
int main(void) {
fprintf(stdout, ">> X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 XA XB XC XD XE XF\n");
for(int i = 0; i < 16; ++i) {
fprintf(stdout, "%XX", i);
for(int j = 0; j < 16; ++j) {
unsigned char num = i * 16 + j;
You can’t perform that action at this time.