Skip to content

Instantly share code, notes, and snippets.

View oknauta's full-sized avatar

Nauta oknauta

  • Paraíba, Brasil
  • 10:24 (UTC -03:00)
View GitHub Profile
@oknauta
oknauta / hello_world.cpp
Last active May 12, 2024 23:21
"Hello, world!" in C++
// hello_world.cpp
#include <iostream>
int main(int argc, char const *argv[])
{
std::cout << "Hello, world!\n";
return 0;
}
@oknauta
oknauta / bad_malloc.c
Last active July 4, 2024 01:41
Creating GARBAGE in memory using C!
// File: bad_malloc.c
// Date: 2024-05-21 | 2024-07-03
#include <stdlib.h> // Library to malloc
#include <stdbool.h> // Library to bool
int main()
{
while(true) // Loop to create the garbage.
{
@oknauta
oknauta / hello_world.c
Last active June 1, 2024 01:04
Prints `Hello, world!` on console in C.
/******************************************
* File: hello_world.c
* Date: 2024-05-20 | 2024-05-31
******************************************/
#include <stdio.h> // The standard library to `Hello, world!` can be printed on console.
// Function that the compiler will search first for.
int main(int argc, char const *argv[])
{
@oknauta
oknauta / sdl2_window_blank.c
Last active June 6, 2024 06:10
Creating a blank window in C with SDL library.
/***************************************************************************
* File: sdl2_window_blank.c
* Date: 2024-05-31 | 2024-06-06
***************************************************************************/
#include <SDL2/SDL.h>
#include <stdbool.h>
#define WINDOW_SIZE_X 800 // Window width.
#define WINDOW_SIZE_Y 600 // Window height.
@oknauta
oknauta / physic.h
Last active July 3, 2024 21:30
Calculating the free fall of an object in C.
/***************************************************************
* File: physic.h
* Date: 2024-05-31 | 2024-06-01
***************************************************************/
#ifndef PHYSIC_H
#define PHYSIC_H
#include <math.h> // Library to `sqrt`
@oknauta
oknauta / ford_car.c
Last active June 11, 2024 04:02
Using `struct` to create an information.
/**************************************
* File: ford_car.c
* Date: 2024-06-11 | 2024-06-11
**************************************/
#include <stdio.h>
#define FORD_BRAND "Ford"
#define FORD_CAR_MODEL "F3310"
#define FORD_CAR_F3310_YEAR 2024
@oknauta
oknauta / glfw_window.cpp
Created July 3, 2024 21:30
Window in C++ GLFW
// File: `glfw_window.cpp`
// Date: `2024-07-03`
#include <GLFW/glfw3.h>
#include <GL/glut.h>
int main()
{
// Initializing glfw
glfwInit();
@oknauta
oknauta / glfw_triangle_white.c
Created July 11, 2024 14:16
A white triangle in C with GLFW
// File: glfw_triangle_white.c
// Date: 2024-07-11 | 2024-07-11
#include <GL/gl.h>
#include <GLFW/glfw3.h>
#include <stdio.h>
#define WINDOW_WIDTH 800
#define WINDOW_HEIGHT 600
#define WINDOW_TITLE "Triangle"