I am just tinkering with fundamentals or defund-a-mental.
In this gist I am playing with reading and parsing files into a struct.
clone:
git clone https://gist.github.com/922015df1109edb1b55adc544ec29de9.git ~/gist.github/mezcel/csv-and-structs.git
Win10
-
- I prefer the CLI over the IDE GUI. (Less configurations, more portable)
- Build bust be performed by the
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\VsDevCmd.bat
shell.- Launch VSCode from this shell if you want to debug
- Run the following scripts:
launchVsDevCmd.bat
and thenmake.bat
. - Or just run:
cl main.c /c functions.c /Fe"main.exe"
- Or
cl /c functions.c; cl main.c functions.obj /Fe"main.exe"
OR
-
MinGw or the Cygwin environment.
- Cygwin packages: gcc-core, automake, make, bash, binutils, cygwin, cygwin-devel, cygutils-extra
Debian
- gcc
sudo apt update sudo apt install -y build-essential gcc gdb
library | Linux | Windows 10 | use case |
---|---|---|---|
#include <stdio.h> |
stdio.h | cstdio.h | printf(), sprintf(), fread(), fopen(), fclose() |
#include <stdlib.h> |
stdlib.h | stdlib.h | calloc(), realloc(), malloc(), system(), free() |
#include <string.h> |
string.h | cstring.h | strcmp() |
#include <time.h> |
time.h | ctime.h | After year 2038, use an x64 compiler |
library | Visual Studio C++ | use case |
---|---|---|
#include <windows.h> |
windows.h | GetConsoleScreenBufferInfo() |
#include <conio.h> |
conio.h | getch() |
library | GCC | use case |
---|---|---|
#include <sys/stat.h> |
sys/stat.h | stat() |
#include <sys/ioctl.h> |
sys/ioctl.h | ioctl(), TIOCGWINSZ, struct winsize |
#include <unistd.h> |
unistd.h | STDOUT_FILENO |
#include <json-c/json.h> |
json-c/json.h | Debian Linux json-c library |
#include "gtk/gtk.h" |
"gtk/gtk.h" | used for Gtk |
The sizeof()
function in Gcc is not the same as Visual Studio's C++ sizeof()
. T
hey are interchangeable for simple arrays, like
char* ch = "word"; sizeof(word)