Category "c"

How to create 24 bit unsigned integer in C

I am working on an embedded application where RAM is extremely tight. For this purpose I need to create a 24 bit unsigned integer data type. I am doing this us

How can I include a C header that uses a C++ keyword as an identifier in C++?

I've been using C++ and compiling with clang++. I would like to include the <xcb/xkb.h> header for an X11 program I am writing. Unfortunately this header

How to reset this string scanning code for a new letter?

I'm in the middle of homework and nearly finish. This is my code #include <stdio.h> #include <stdlib.h> void main() { char word[100],*ptr,input

C print first million Fibonacci numbers

I am trying to write C code which will print the first 1million Fibonacci numbers. The actual problem is I want to get the last 10 digits of F(1,000,000) I unde

Using setjmp and longjmp with a local jmp_buf

In the case that a local jmp_buf is actually represented by registers rather than stack memory, is it possible for setjmp or longjmp to cause the contents of th

OpenCL - clEnqueueNDRangeKernel - output array becomes input array

I perform a 5-point stencil operation on a 2D array until getting a convergence computed on this 2D array. So I have multiple iterations (until convergence) and

How to set up Raspberry Pi 4B as a I2C slave

I'm trying to set up a RPi 4B to work as an I2C slave with PSoC (4.4) - CY8C5888LTI-LP097. Below is my code to set up the slave address on the Pi. import pigpio

I can't figure out why it works half the time

My own minesweeper I am trying to make #include <time.h> #include <conio.h> #include <stdio.h> #include <stdlib.h> int randNum(int min

Reading multiple lines in C using fscanf

i'm currently doing an uni project which has to read a multiple lines sequence of inputs given in a .txt format. This is my first experience with C, so i don't

Anaconda confuses C/C++ linker with duplicate libraries

This is happening on a Linux system. Anaconda comes with several C libraries, like libz, or libgomp. I have most of these libraries also installed globally on m

How to get the time difference between two times (24h format)

I am currently trying to create a program where the user gives two values (times, hh:mm:ss) and gets the difference between the two times. This works, if one wo

How to export matlab matrix to .txt in a format supported by c

As I state in the title, I want to export a matrix from matlab to a .txt file in format that is supported by C. What I mean is something like this { { 1, 2, 3,

configure: error: cannot run C compiled programs

I'm trying to install different software onto my Raspberry Pi with Debian Wheezy OS. When I run try to configure software I'm trying to install I get this outpu

UEFI function running wrong part in if else

I am writing a UEFI function which used to show status. But when I give it a EFI_STATUS type "2" as "state" argument, it execute "else" part, instead of "state

Why is socket linger used after socket close?

I looked at documentation about this but shouldn't a socket linger be declared before the close so the program doesn't immediately abort before it knows what ki

stm32-h743zi nucleo-144 ADC

i have a problem with getting value from ADC on the nucleo144 board. I connected a potentiometer to the pin A0, but the ADC is stuck in the HAL_PollForConversi

Libtool: link: unable to infer tagged configuration

I am trying to cross-compile linphone for ARM. I configure it using ./configure --host=arm-linux-gnueabi --with-gnu-ld --disable-static --disable-glib --with-o

tcc: error: undefined symbol '_GetConsoleWindow@0'

I'm making a program in C/C++ which must run hidden using this code: #define _WIN32_WINNT 0x0500 #include <windows.h> int main(){ HWND hWnd = GetCons

Checking whether space should be printed in the middle or at the end in for loop?

I am trying to give info to my program whether it should print space or not. My code looks something like this, and its printing spaces at the end (which is not

Lua set default error handler

The default lua_pcall error handler (as of Lua 5.3) does nothing, letting the exception message remain on top of the stack. We would like to change this so we g