Category "c"

I am trying to load words from a text file into a binary search tree

I am trying to load words from a text file into a binary search tree. Each line of the file contains one word. #include <stdio.h> #include <stdlib.h>

Itering and compare struct element with different size

I've a tricky question and I don't know if there is any solution. Basically I've populated a struct using x-macros, for example with the following macro: #defin

How can I get random numbers between 1-7 in kernel using get_random_bytes()?

int random_ticket; get_random_bytes(&random_ticket, sizeof(random_ticket)); I tried to do it like this but I think this method gives random numbers between

Itering and compare struct element with different size

I've a tricky question and I don't know if there is any solution. Basically I've populated a struct using x-macros, for example with the following macro: #defin

What's purpose of __linecapp in getline, when it'll auto resize?

It's all about second parameter of getline in stdio.h, I'll name it 'n' or '__linecapp' below. According to the document: If the buffer is not large enough to

MacOS CoreAudio buffer playback produces annoying noise

MacOS CoreAudio buffer playback produces annoying noise between correct sound. I'm interested to play valid .wav data though the buffer. Why I'm playing a .wav?

Linked List Deletion function causing program to crash *wrong pointers?*

In my program when a username is following another one and also has posted a "tweet" which is a string in an attempt to delete the followed username it breaks t

WordNet functions fail for non-base forms of words

I'm using the C API for WordNet. When I try the following code with the word "dog", it correctly tells me that "dog" is a noun. However, if I pass "dogs", it re

Force compiler to use static definition from a specific C file

Two C files have the same variable name declared differently. Can I force the compiler (Visual Studio or gcc) to prefer one declaration over the other? The scen

mktime() for non-local timezone

In C the function mktime() returns the epoch time according to the local timezone (the input struct is locally formatted). The function timegm() returns the epo

how to use pipe and execvp in c via linux

I'm trying to use pipe command and I can't understand how to. I've a lot of versions but I can't make it work. first of all the hierarchy: main prog - nicecmp -

Modify user input to use in exec call

I am trying to modify a user input string to call execvp in a future function. In my code I have a function which tokenises the user input such that if the user

Raspberry Pi GPIO automatically resets to 0 using linux ioctl's

I have a relay connected to GPIO26 driven by a transistor on a Raspberry Pi 4. When the logical pin is set to 0, the relay is normally closed (delivering curren

Making a lexer piece by piece and am struggling with reading operators correctly

I am pretty new to coding and am working on a lexer project for school. I have made it so it can register everything as tokens and have been expanding its abili

NEO 6M GPS does not respond to configuration except if commands are sent immediately after powering up gps

I am trying to configure my neo 6m GPS to stop automatic sending of information. I used Hterm serial terminal to send the proprietary messages ($PUBX,40,GLL,1,0

How to open a text file in C

In my text file, there are random binary numbers written in a 10x10 matrix. I want to print them in C exactly as they appear in the text file. So I made my code

Using local variables with functions that take pointers in FreeRTOS

I need some explanation/clarification about using local variables in FreeRTOS when I need to pass them to another functions as pointers. For example I have some

Two way communicating with pipes - in the correct order

I have a small program to demonstrate two way communication with pipe between parent and child processes. I already asked a question about this (Two way communi

Errors about scanf and printf expected types

My issue is coming from the %c name input, I am getting an error that it is expecting type char * but has type char * [15] for the scanf function. I am also ge

Makefile with arbitrarily many mains. How to compile all mains with one command?

I am still newish to makefile patterns. I have been working on a project based on a template makefile and project structure, however I have a good sense of what