Category "c"

Different C++ fork() behavior between CentOS 7.5 & RockyLinux 8.4, Ubunu 20.04

I'm working with some legacy code. It works fine on a CentOS 7 system. The args array gets hosed on both a Rocky 8.4 and Ubuntu 20.04 system. I've simplified th

GTK treeview: disable highlight when selected

I try to disable highlight on a row when it is selected for a GtkTreeView widget (default is blue background and white text color). I tried to change the STATE_

Error: Called Object is Not a Function or Function Pointer [Need Help]

//File Name: "track_distance.h" #ifndef TRACK_DISTANCE_H_INCLUDED #define TRACK_DISTANCE_H_INCLUDED typedef struct Point_struct { float x; float y; }

How do I convert a number to a string without using stdlib.h or string.h?

Here is my exercise: Write a function that receives from the user two strings that show two real numbers (possibly negative), And produces a string that contai

Load and use a Glade layout in GTK2/C

I was trying to load a Glade layout into a GTK2 C code. It consists of a window in which there is a VBox with 2 elements: a label and a button. I want to associ

Where do the values of uninitialized variables come from, in practice on real CPUs?

I want to know the way variables are initialized : #include <stdio.h> int main( void ) { int ghosts[3]; for(int i =0 ; i < 3 ; i++) printf(

Trying to use a bool to move stepper motor only once, if bool / latch is removed it works in loop but in current set up it does not run. Any ideas?

I'm trying to run a stepper motor a fixed number of steps before stopping. I'm having trouble implementing the bool has_run variable. I've carried out debugging

MinGW Debugger in VS Code is Stuck at Building tasks. What can I do to get it back to normal? I

Earlier it used to create the .exe files whenever I hit the F5 button to debug the code. But now for some reason I am unable to get it right and I messed up wi

Pairwise Balanced Incomplete Block Design in C

I have to make a pairwise BIBD in C (using backtracking), but i don't know how to generate the blocks and check for pairs of points I thought I could make a 2d

Why does it iterate one more time even if it is NULL?

Similar question here . What I want to understand is that when current_node is NULL, the compiler doesn't see it as NULL and iterates one more time. void pr

writing to FILE for transmission over USART

I have a bit of code written by someone else that I'm trying to understand. I'm familiar with c enough to make basic/intermediate functions, but never really le

How to do multiple aio_writes to file

When doing multiple aio_writes to file is it necessary to wait (e.g. aio_suspend or other) before starting the next one? From the documentation it says that wri

How are char arrays / strings stored in binary files?

When I compile this code using different compilers and inspect the output in a hex editor I am expecting to find the string "Nancy" somewhere. #include <stdi

Seven segment project using atmega16 and external interrupts

I have been working on a simple project on AVR microcontroller atmega16 on proteus simulation. The project is: When I push the push button it increments the sev

Don't understand OpenSSL API error handling

I'm implementing a little HTTP client using OpenSSL, and I'm trying to handle "connection timed out" errors gracefully. By gracefully, I mean I want to print a

How to construct a string where every char is doubled?

TL;DR: I am asking you to tell me what would be the most efficient approach to double my strings and print them out? Full story: I had trouble with the title,

Epoll_wait() Does Not Recognize Client

I tried to make a simple server-client protocol where the server sends a set of fragmented files to clients, each client gets a fragmented file. I ran into an i

Pointers - Strings

I have a code chunk which is quite meaningless for me. Is there someone can explain it to me? Thanks int strLength(char *str) { char *p = str; // Go until the e

Programming STM32H747 ADC in continuous mode using registers only

Within a project of mine I use DMA to share data between the two cores of the STM32H747, the data comes from an ADC controlled by the core M7. While testing my

In C, I'm having trouble getting an Index sorted High to Low and vice versa

I'm working on a project involving a preset array: primaryArray[8] = {8, 4, 2, 16, 32, 124, 64, 256}; Im calling a function before the main, its not quite worki