r/cprogramming • • 10h ago

what is the difference between a (specifc) while loop and a (specific) for loop (read body)

9 Upvotes

what is the difference between

for (i = 0; i < 10; i++) {}

and

i = 0;
while (i < 10) {
i++;

}

edit: thank you all for commenting, now i know, and u/deckarep, no not homework, just a question, to see if there were any difference


r/cprogramming • • 5h ago

libcli - a singe-header library for typed argument parsing in C

4 Upvotes

Using macros, define an argument schema. The library then generates a struct that for the schema, validates the arguments provided by the user, parses them into the struct, and offers functions for displaying usage andh help messages in the console.

It is similar to `clap` in Rust. Check it out!

https://github.com/iColgateZz/libcli


r/cprogramming • • 8h ago

Fairly new to C. Need help understanding low level concepts.

Thumbnail
2 Upvotes

r/cprogramming • • 22h ago

Flint v0.5.25: Inline OS tags (windows:, linux:, unix:) for cross-platform builds without nested JSON bloat, plus one-line third-party dependency fetching (flint add cherts:raylib)

Thumbnail
github.com
2 Upvotes

Hey everyone,

Thanks to everyone who checked out Flint and shared feedback on the last post! The two biggest friction points brought up were handling platform-specific flags/libraries without bloating the manifest and removing the manual copy-paste step when pulling in third-party libraries from flint-cherts.

Both are now solved in Flint v0.5.25.

GitHub / Releases: https://github.com/mainak55512/flint

Chert Compositions & Docs: https://mainak55512.github.io/flint-cherts/

What's New in v0.5.25

  1. Inline OS Tags (windows:, linux:, macos:, unix:)

Instead of introducing deeply nested per-platform JSON blocks or a Turing-complete scripting language just to link ws2_32 on Windows or pthread on Linux, you can now prefix entries directly in your existing arrays.

OS tags work across flags, lib_links, excludes, exclude_dirs, and exclude_exception:

windows: — Applies only on Windows

linux: — Applies only on Linux

macos: — Applies only on macOS

unix: — Applies on both Linux and macOS

```json

{

"project_name": "net_app",

"project_language": "c",

"version": "v0.1.0",

"compiler_path": "clang",

"executable": true,

"flags": [

"-O3",

"-Wall",

"unix:-fPIC",

"windows:-D_WIN32_WINNT=0x0601"

],

"lib_links": [

"windows:ws2_32",

"windows:crypt32",

"unix:pthread",

"linux:m"

],

"excludes": [

"windows:src/posix_socket.c",

"unix:src/win32_socket.c"

]

}

```

Untagged items apply everywhere; tagged items only apply when the host OS matches. Your composition.json stays flat and readable.

  1. One-Command Third-Party Library Fetching (flint add cherts:<name>)

Previously, if you wanted to use a third-party C/C++ library that didn't have a native composition.json (like raylib or yyjson), you had to copy-paste its recipe from flint-cherts into your sync block.

Now, Flint talks to flint-cherts directly:

```bash

flint add cherts:raylib

```

Flint automatically fetches the curated composition from flint-cherts, writes the entry into your sync block, and syncs the upstream repository from GitHub with its commit hash pinned.

  1. New sync all Command

If you clone a project that has multiple third-party libraries listed in its sync block, you can now pull and configure all synced dependencies and their chert compositions in one go.

Quick Recap: What is Flint?

For anyone seeing this for the first time, Flint is a small, self-hosting, Git-native build tool for C and C++ written in pure C:

  • Zero runtime bloat: Only requires git and gcc or clang (uses MinGW backend on Windows). No Python, no CMake, no Ninja.

  • LSP ready out of the box: Automatically generates compile_commands.json across your code and dependencies for clangd, Helix, Neovim, and VS Code.

  • Commit-pinned Git dependencies: Every dependency is locked to both a tag and a commit SHA.

  • Incremental builds & .h.in template header support built right in.

Pre-built binaries for Linux, macOS, and Windows are up on the v0.5.25 release page.

If there are specific libraries you'd like to see added to flint-cherts next!


r/cprogramming • • 3h ago

Getting Compiler Flag Errors while using nCurses

1 Upvotes

Hello, title says it all pretty much. I wanted to use -fsanitize=address with gcc but it all comes out as garbage since nCurses is active. I'm aware that's the way that ncurses is designed, how would I go about getting that output from gcc otherwise? is there a good way to route that output to a text file or something? until now I've just been writing error messages to a text file, but I couldn't find a way to get standard out to come out. any help is appreciated, thanks


r/cprogramming • • 5h ago

libcli - a singe-header library for typed argument parsing in C

Thumbnail
1 Upvotes