r/cprogramming • • Oct 29 '25

Nesting types

1 Upvotes

Coming from Cpp if I have nested types, the outer pretty much acts like a name space for the nested type so if I had a struct x with another struct y inside I would access y using x::y. Since C doesn’t have scope resolution/namespaces, how would things change if I were to have nested structs? I’m also confused on if and how typedef would affect things as well.


r/cprogramming • • Oct 29 '25

next number with distinct digits

1 Upvotes

hey guys. im writing a program thats supposed to receive a number as an input and then output a number larger than the original one that has all distinct digits. for example you input 1233 and it gives you 1234. for now i have this:

int main()

{

int x;

scanf("%i", &x);

int r = 0;

int y = x;

for (int i = 0; i < 100; i++){

y += 1;

int N = y;

int digits[100];

while (N != 0){

r = N % 10;

digits[i] = r;

N /= 10;

}

for (int j = 0; j <= i; j++){

for (int k = 0; k <= i; k++){

if (digits[j] == digits[k]){

break;

}

}

}

}

printf("%i", y);

return 0;

}

but all it does is output the number + 100. feel free to call me stupid or whatever but i tried to fix it and only ended up with no output at all so any help is appreciated. also please keep in mind i cant use any libraries except stdio. thank you all in advance


r/cprogramming • • Oct 24 '25

What IDE do you use for C/C++?

88 Upvotes

I use Devcpp 5.11 since thats what i use in hs as a freshman, its pretty simple.


r/cprogramming • • Oct 25 '25

C actually don't have Pass-By-Reference

Thumbnail
beyondthesyntax.substack.com
0 Upvotes

r/cprogramming • • Oct 23 '25

What is the Best way To Learn C programming

7 Upvotes

Hi, i just learned some basics of c ,and i want the best way to master it beside learning Linux, and if there project or something related to that,i appreciate ur help,thank you all


r/cprogramming • • Oct 22 '25

Created DSS, a Generic Dynamic Byte Buffer for C. Seeking ideas on advanced strategies and algorithms for memory expansion.

5 Upvotes

I would like to share my recent project, dynamic byte buffer library for C, called DSS, packed with a variety of useful APIs. This project is inspired by SDS (Simple Dynamic Strings for C), but extends it with internal reference tracking and copy-on-write based APIs. Unlike conventional C string libraries, DSS allocates metadata and the string buffer in one contiguous memory block, minimizing allocation overhead and improving cache locality.

I have taken an aggressive approach to memory expansion, which has produced some interesting results in my test experiments that are discussed in detail in the benchmark section of the repository.
I have also prepared a detailed report with experiments that analyze the speed and memory usage in variety of workloads, as well as discussed potential areas for improvement.

While this approach has increased speed, it has also led to higher memory usage. You can explore the related implementation in the dss_expand function.

I’m looking to refine the memory expansion strategy and would really appreciate suggestions on alternative approaches and algorithms.
I’d prefer not to replicate SDS’s method, but rather experiment with new techniques that could yield more insightful results.

Additionally, I would love to get feedback and reviews on the project overall, particularly ideas for:

  • New APIs or features that could make DSS more powerful or flexible
  • Better memory expansion techniques/algorithms, since that’s a critical part of any dynamic buffer

Please find the REPO HERE.

Thank you!


r/cprogramming • • Oct 22 '25

Compile time constants vs run time

2 Upvotes

I’m having a hard time wrapping my head around the idea of compile time constants vs run time. I understand compile time and run time itself, pretty much compile time is where it’s running through the code and turning it into machine code (compiler and linker) and runtime is when the code is actually running on a machine. I also understand that compile time constants are going to be values that the compiler can evaluate and see without running code. When it comes to compile time constants I just don’t understand because in C, const int y =5; , y isn’t a compile time constant but wouldn’t the compiler see y?

I also understand something like the return value of foo(); would be a run time thing since you need to actually run code to get the return value.


r/cprogramming • • Oct 21 '25

I built a real-time JIT engine in pure C (60 live demos, instant execution)

Thumbnail
youtu.be
75 Upvotes

I’ve been working on a live JIT engine that compiles and runs C code instantly, no build step, no waiting.

It feels like interpreted code, but runs with native performance.

Each .jc (JIT C) file is compiled and executed in real time.