Saturday, December 26, 2020

A millisecond Timer in C


Here is one possible implementation of a millisecond timer in C using time.h and ts.tv_nsec
Proof of concept:  Timer Source code
A simpler, more compliant version can be found in repository.

Saturday, December 5, 2020

New Horizons

Google Sheets & Javascript

GOOGLE SHEET MANIPULATION

Spreadsheet link

WORD TRANSLATION
COMMENT
[+] Words:

>> Translation:

Result:

Table:

Saturday, November 14, 2020

A one-line formula to add the digits of a 2-digit number using mod

Adding two digits of a number is the same as subtracting 9 multiplied by the number in the tens from the original number. This formula uses mod(%) to isolate such number and provides the result of the addition of the 2 digits of a given number from 11 to 99:

From: x- (((x -(x mod 10)) / 10) *9)
To: f(x) = x - (1/10(x - x mod 10))× 9
Example: 23 -> 2+3 = 5 | 23 - (9*2) = 5 | 23 - (((23 - (23 mod 10)) / 10) * 9) = 5 
Sample in Ctwodigits




Friday, August 28, 2020

Asteroid Game

Screenshot of the remake of the classic game Asteroid with SDL2 in pure C.

[+] Code:
First commit and subsequent development: 

[+] Game Structure:






Monday, August 6, 2018

One version of kbhit() using windows API


Here is one version of kbhit() using windows API (GetAsyncKeyState). It runs through 255 possible key scancodes in pulses. If a key is pressed, it returns 1 and the value of the key pressed by reference.
This can be used to make a rudimentary keylogger in Windows.
Proof of concept:  Keylogger Source code

#include <windows.h>
Prototype: int kbhit(char *ch); 
Call:
int keypressed=0;
char ch=0;

keypressed = kbhit(&ch);







Saturday, July 21, 2018

Listing files recursively in C in a menu with scroll.


One of the most complex programs I've ever written which makes use of my latest development with list boxes in C. You can navigate and change path while the different files and directories in the new path are added to the dynamic list for scroll.


>> SOURCE CODE <<

Saturday, July 14, 2018

Segmentation Fault - C Pointers


Segmentation Fault!!!

I have seen this phrase so many times I may end up having nightmares with it. But I got there in the end!! In my experience,  it seems the only way to learn how to use pointers properly is through trial and error. :D

This time I've used them to develop a ListBox in C with scroll capabilities.
As usual you can find it in my github repository. (Code available for Linux, Windows and DOS).

Cheers!

Demo: