Skip to content

Instantly share code, notes, and snippets.

View Alynva's full-sized avatar
🤔
Thinking

Alisson Nunes Alynva

🤔
Thinking
View GitHub Profile
@Alynva
Alynva / colors.cpp
Last active February 10, 2017 18:44
Changing de output color on Windows terminal
#include <iostream>
#include <windows.h>
using namespace std;
int main() {
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
// you can loop k higher to see more color choices
for(int k = 0; k <= 255; k++) {
// pick the colorattribute k you want
@Alynva
Alynva / Input.c
Created February 10, 2017 18:57
Exemplifies the usage of a mouse in console environment. Purely coded in C using gcc compiler (MinGW, to be more precise)
#include <windows.h>
#define MAXCONSOLEINPUTS 20
//This is the input module. It can handle not only Mouse but keyboard also.
HANDLE rHnd, wHnd; //Handles for reading and writing to the console.
//The Mouse Handle function. Or to be more precise, the pointer to the function
int (*handler) (int x, int y, int button,int state);
int initializecontrols();
int addmousehandler(int (*func) (int x, int y, int button,int state));
@Alynva
Alynva / converMedidas.c
Last active February 11, 2017 14:53
Programa em CGI para converter unidades de medida
#include <stdio.h>
#include <stdlib.h>
int main() {
char* dados = NULL;
int input1 = 0, convert = 0, i;
double result1 = 0.0;
char erro[50] = {'\n'};
char select[7][70] = {'\n'};
@Alynva
Alynva / jogo-da-forca-theWord.c
Created February 11, 2017 14:59
Jogo da Forca em CGI
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
int main() {
int i;
char *dados = NULL;
char theWord[50] = {'\n'};
@Alynva
Alynva / jogo-da-memoria.c
Created February 11, 2017 15:05
Jogo da Memória em CGI
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define QTDNUMBERS 5
void getName(char[], char[]);
int main() {
@Alynva
Alynva / jogo-da-velha.c
Created February 11, 2017 15:09
Jogo da Velha em CGI
#include <stdio.h>
#include <stdlib.h>
int main() {
// 0 = não jogado
// 1 = jogado o "O"
// 2 = jogado o "X"
char* dados = NULL;
@Alynva
Alynva / jogo-de-pintar.c
Created February 11, 2017 15:18
Jogo de Pintar (Paint) em CGI
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#define MAXPIXELSTRING 71910
#define MAXPIXEL 4794
int main() {
int i = 0;
int j, k;
@Alynva
Alynva / SDL Message Box.cpp
Created April 8, 2017 12:38
A little example of SDL Message Box
#include "SDL.h"
#include <windows.h>
int main(int argc, char *argv[]) {
const SDL_MessageBoxButtonData buttons[] = {
{ /* .flags, .buttonid, .text */ 0, 0, "no" },
{ SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "yes" },
{ SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 2, "cancel" },
};
const SDL_MessageBoxColorScheme colorScheme = {
@Alynva
Alynva / funcs.cpp
Created May 21, 2017 23:31
A function as a parameter of another function
#include <iostream>
using namespace std;
int f1(int n) {
return n * 3;
}
int f2(int f(int), int n) {
return f(n) - 2;
@Alynva
Alynva / to_string.cpp
Last active October 29, 2017 12:07
Convert anything to string
#include <string> // std::string
#include <iostream> // std::cout
#include <sstream> // std::ostringstream
using namespace std;
template <typename T>
string to_string ( T Number ) {
string Result;
ostringstream convert;