Category "c"

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

How to represent sparse matrix (including zero elements) in C using linked list?

I want a code that represents a sparse matrix including zero elements using linked list, I basically want the output to be like this: 1 0 0 0 0 6 1 0

Encrypting a video file with the 3DES algorithm

I am encrypting a video file using 3DES algorithm and ffmpeg library.In my program, I use two channels, each connected to its own instance of FFmpeg. Basically,

fread a float array after a fwrite immediately will cause a file offset problem

Initial the integer array[] right line 21 will cause the failure of the data[] array fread from data.txt . int main() { FILE * file0 = NULL;

Why is my print function giving the wrong output in my program to print strings?

The expected outcome is for example: a word a sentence This is the outcome tho: aword word a sentence Here's the code: #include <stdlib.h> #include <

Why Segmentation Fault for this below code? [duplicate]

This following code gives Segmentation fault: #include <stdio.h> int main() { char* str = "hello world"; str[0] = 'H'; // it is

initialization of 'const char **' from incompatible pointer type 'char *'

I am new in learning C. I have an issue in returning double star pointer from the function. This is my code. #include <stdio.h> #include <stdbool.h>

Are "thread storage duration" and "thread local storage duration" the synonyms?

C11, 6.2.4 Storage durations of objects, 4 (emphasis added): An object whose identifier is declared with the storage-class specifier _Thread_local has thread s

Is this defining the struct pointer address?

I am a bit lost in the following piece of code. What does it mean? Define the the Elf pointer start position? #define ELFHDR ((struct Elf *) 0x10000) Aft

Unexpected output when printing to 0xb8000 - osdev

I'm developing a kernel and when I try to print to video memory(0xb8000) I get weird characters when I run it. What I have tried: I have tried to find some answ

Remove an element from array of structs with pointers

I have to implement the appointmentData_remove function which removes an element of type tAppointment from the tAppointmentData array. Data types are defined li

Getting a stack overflow exception when declaring a large array

The following code is generating a stack overflow error for me int main(int argc, char* argv[]) { int sieve[2000000]; return 0; } How do I get around

Eclipse throwing "Unresolved inclusion error" on standard includes like "stdio.h"

After installing Eclipse freshly on Windows 10, I imported code to work on, but Eclipse started throwing the error "Unresolved inclusion error" on standard libr