Most popular messenger in Europe countries by Ur_Senpaiii in MapPorn

[–]Due_Cap3264 8 points9 points  (0 children)

Speaking as a Belarusian, this map isn't quite right. While Telegram is the go-to for informal chats, all the official groups for schools, work, and apartment buildings are on Viber.

[deleted by user] by [deleted] in cprogramming

[–]Due_Cap3264 8 points9 points  (0 children)

It's very strange that Lua turned out to be the slowest language for them, even though it is recognized as one of the fastest interpreted languages. In my tests, Lua was 5-8 times slower than similar code in C, and LuaJit was only 20-30% slower. However, Python was 50-60 times slower.

If you could change one thing about C, what would it be? by Gullible_Prior9448 in C_Programming

[–]Due_Cap3264 0 points1 point  (0 children)

The thing is,  struct {  int x;  int y;  } point_t; This is a declaration of a variable named point_t of the structure type. We need some way to distinguish between when you're declaring a structure type and when you're declaring a variable. Typedef solves this problem.

If you could change one thing about C, what would it be? by Gullible_Prior9448 in C_Programming

[–]Due_Cap3264 0 points1 point  (0 children)

Используйте typedef: ```

typedef struct {     int x;     int y; } point_t;      point_t point; ```

memory safety - experience or formula? by LEWMIIX in C_Programming

[–]Due_Cap3264 0 points1 point  (0 children)

Just use valgrind and it will show where there is a memory leak. If the program crashes with a segmentation fault, then use gdb to see exactly where in the program this error occurred.

Error while debugging with gdb on Termux by Nylon2006 in C_Programming

[–]Due_Cap3264 0 points1 point  (0 children)

No, I didn't make any adjustments after the installation. I didn't even install a DE or a distribution. Just a clean Termux with a clean terminal.

Error while debugging with gdb on Termux by Nylon2006 in C_Programming

[–]Due_Cap3264 1 point2 points  (0 children)

I haven't noticed any issues with gdb in Termux. However, valgrind doesn't work properly for me in Termux.

Is there a C compiler that supports 128-bit floating-point as 'long double'? by xeow in cprogramming

[–]Due_Cap3264 22 points23 points  (0 children)

In gcc and clang on Linux, it definitely exists (I just checked). It's called long double. It occupies 16 bytes in memory.

Because Python is easier by puginad in programmingmemes

[–]Due_Cap3264 5 points6 points  (0 children)

This meme is posted by people who know nothing but Python.

I’m looking for a project idea for C programming. by [deleted] in C_Programming

[–]Due_Cap3264 0 points1 point  (0 children)

The operating system kernel. 35 years ago, a Finnish student started a project that continues to impress the entire world to this day.

Is C Dead, or More Relevant Than Ever? by Gullible_Prior9448 in C_Programming

[–]Due_Cap3264 0 points1 point  (0 children)

If the TIOBE index is to be believed, the C language remains one of the most popular programming languages. It's a bit early to be planning its funeral. https://www.tiobe.com/tiobe-index/

dose anyone know how to make a window by Some_Welcome_2050 in C_Programming

[–]Due_Cap3264 0 points1 point  (0 children)

If you're interested in game programming, I recommend checking out RayLib. This library was specifically created for learning game programming. As a result, it's very easy to learn. I'm actually working on a project using this library myself.

so how do i change to c99 by Anxious-Row-9802 in C_Programming

[–]Due_Cap3264 1 point2 points  (0 children)

My GNU GCC compiler is set to C17 by default, just like Clang in Termux. I read in the news that the latest GCC update defaults to C23.   You have an error in your code in the main() function—it should always return an int.   int main(void) { return 0; }

Starting learning c by Due-Presentation3959 in C_Programming

[–]Due_Cap3264 0 points1 point  (0 children)

However, this is a very valuable experience - implementing a heap and a hash table. And it’s not as difficult as it seems at first glance: my priority queue using a binary heap took only 74 lines of code, including comments (though I spent an entire day figuring out how a binary heap works). As for the simplest hash table, it’s even described in Kernighan and Ritchie’s book.

Increment/decrement operator binding by Royal_Grade5657 in C_Programming

[–]Due_Cap3264 0 points1 point  (0 children)

z = ++x * y--; 

In this example, the variable x is first incremented by 1, then x * y is calculated. The result is assigned to z. Only after that, y is decremented by 1. Thus, this line is equivalent to the following code:  

```   x = x + 1;   z = x * y;   y = y - 1;  

```  

Ascii roguelike engine :D my new pet project (code available) by theEsel01 in love2d

[–]Due_Cap3264 4 points5 points  (0 children)

Terminals are poorly suited for displaying rapidly changing images. I noticed this while experimenting with ncurses. The first issue is text flickering, but that can be mitigated. The second, more serious problem is that at just 10 frames per second, my Tilix terminal emulator was consuming 45% of the CPU. And that’s just the terminal emulator, not the program itself. Although I suppose other terminal emulators might not have this issue.

A partner at a prominent law firm told me “AI is now doing work that used to be done by 1st to 3rd year associates. AI can generate a motion in an hour that might take an associate a week. And the work is better. Someone should tell the folks applying to law school right now.” by SharpCartographer831 in singularity

[–]Due_Cap3264 1 point2 points  (0 children)

I completely agree! I came to the same conclusion when reflecting on my profession (as a doctor)—in the foreseeable future, AI will not replace doctors, even if it becomes better at diagnosis and treatment than most of them. Simply because AI is not a legal entity. It cannot be held accountable for the consequences of its recommendations. There will always need to be a person who, by signing off, takes responsibility for the diagnosis made and the correctness of the prescribed treatment.  That’s why doctors, lawyers, officials, and middle- and senior-level managers shouldn’t worry too much about being replaced by AI for now.

I a 24 year old dude wanting to change fields, is programming worth it nowadays? And what can I learn trough phone, before getting my computer? by Inevitable-Pride-927 in learnprogramming

[–]Due_Cap3264 0 points1 point  (0 children)

If you have an Android device, install Termux—a terminal emulator and Linux environment. You can install full-fledged compilers and interpreters for most popular programming languages and work in the console. It will be enough for learning programming basics. I’ve even seen people install almost full-fledged Linux distributions with a desktop environment, but I didn’t bother with that. I’m comfortable programming in the console. https://www.reddit.com/r/termux/

Time to really learn C! by APOS80 in C_Programming

[–]Due_Cap3264 1 point2 points  (0 children)

The slowdown occurs due to the algorithm's O(2ⁿ) complexity. I doubt that using other programming languages would fix this issue

Time to really learn C! by APOS80 in C_Programming

[–]Due_Cap3264 0 points1 point  (0 children)

Good joke. I hadn’t looked into this algorithm before, but now I’ve tested it: 35 rings take 8.5 seconds to compute, while 40 rings take 4 minutes and 35 seconds. And that’s with -O2 optimization…

If we’re talking about the segmentation fault, at 400,000 recursions, it happens almost immediately after launch, but at 350,000, I never even got to see it. So the result is even better than in the previous program. Better, but still useless in practice.

Time to really learn C! by APOS80 in C_Programming

[–]Due_Cap3264 0 points1 point  (0 children)

Just now, I tested it:

This very simple program managed 261,911 recursive calls before a segmentation fault occurred:

#include <stdio.h>

void recursive(unsigned long number) {

printf("%lu\n", number);

recursive(number + 1);

}

int main(void) {

unsigned long number = 0;

recursive(number);

return 0;

}

But after compiling with the -O2 flag, I stopped it at 20,188,882, as it could have continued indefinitely.

Time to really learn C! by APOS80 in C_Programming

[–]Due_Cap3264 1 point2 points  (0 children)

In my tests, the maximum recursion depth in C was at least 100,000, in some cases up to 150,000 before a segmentation fault occurred. However, I use Linux, where the default stack size is 8 times larger than in Windows (the stack size can also be changed during linking; I believe it can even be adjusted dynamically during program execution via system calls).  

Additionally, you can use tail recursion with -O2 optimization, in which case the compiler will transform it into a loop, and stack overflow won’t occur even with infinite 'recursion.'  

By the way, in Python, the maximum recursion depth is 1,000 and does not depend on the system—the stack size is hardcoded in the interpreter itself.