Category "c"

Can I call linux allocation API functions in C?

I want to allocate physical page frames using alloc_pages() in C. I have tried that in kernel module in it works fine. I want to make the code running in user s

How does printf("%d",x) work/interpreted?

I am wondering how exactly printf("%d",x) is interpreted. All I know that the compiler reserve a memory to put '%','%d','\0' and returns its address to printf,

How to compile the LIBVLC example code on windows using gcc

I want to build the libvlc example (https://wiki.videolan.org/LibVLC_Tutorial) so i downloaded the sources and also copied libvlc.dll and libvlccore.dll (from m

Compilation error C2048 while compiling in visual studio 2019 MSVC, but works fine with clang++?

I tried to compile the following sample code with clang compiler and it works fine. Compiler Details: Apple clang version 12.0.0 (clang-1200.0.32.28) Target: x

How can I configure this code to use a file name with space(ie: hello world.c ) in Vs code terminal? I mean where is the error here?

Windows 11|| Vs Code version 1.67.1.0 || Power Shell 7.2.3 I have a filename with a space in it like hello world.c, and I want to compile this from VSCode. The

C Programming, scanf() function output [closed]

When I run the program on a Cygwin terminal, I am not able to achieve the following output: 38 $92360.88 llama Notepad++ Cygwin Terminal Progr

TensorFlow static C API library - how to link with 10 sub-dependencies?

I am trying to link with static C API version of the TensorFlow library. I built the static library using the following commands: // get the sources git clone h

Undefined reference to GetConsoleWindow

I am trying to get a handle for the console window with the following: #include <Windows.h> #include <stdio.h> #include <stdlib.h> #define N

Retrieve Linux Time using struct timespec

Can someone please suggest how can I retrieve linux time using struct timespec ts type? It just gives me time since Epoch. Can I get the actual Linux tim

How to cross compile a c program to aarch64 with cpuid.h?

I'm trying to cross-compile a simple C program to aarch64 (arm64) from a 64bit Ubuntu Linux. Can someone please help me why i'm getting this error. It says 'cpu

is END OF FILE (EOF) right after the end of text or depends on the compiler?

I just started learning files in c few days ago. In order to understand how to manipulate correctly the functions, I wrote a code who create a new file (w+) rea

Marshaling complex C structs with c unions for C#

i am desperate to get a complex c datatype correctly marshaled for C#. I already read all the other posts regarding that topic and i am running out of ideas alt

Which of these answers are the equivalent of O_RDWR on Ubuntu 14.04 LTS?

I have been given a list of the following check box containing all possible solutions to the question of choosing all true answers equivalent to O_RDWR on Ubunt

linux fcntl file lock with timeout

the standard linux fcntl call doesn't provide a timeout option. I'm considering implement a timeout lock with signal. Here is the description of blocking lock

Cygwin: C standard library does not support TIME_UTC and timespec_get?

Sample code (t667c.c, taken from here): #include <stdio.h> #include <time.h> int main(void) { struct timespec ts; timespec_get(&ts, TIM

Optimal Selection for minimum total sum

This is a problem from competitive programmer's handbook: We are given the prices of k products over n days, and we want to buy each product exactly once. Howev

How to use compile GTK in C on Mac OS

I'm getting started in c and would like to create GUI, so I tied using GTK. I followed the tutorial they gave on https://www.gtk.org/docs/getting-started/hello-

Input: a2b3c4 and Output: aabbbcccc

The code I've written is not producing any output. It just takes the string as an input: #include<stdio.h> #include<conio.h> #include<string.h&g

How can I correctly display all the elements of 2D array that have even neighbors?

I wrote a program that finds and displays all the elements in the 2D array, which have all neighbors(left, top, right, bottom) - even. I tried to put in an if,

How can I safely add and clamp a signed integer in C?

I have a value, of type signed int, which is always clamped between, for example, ±1073741824 (2^30). I should be able to safely add or subtract any arbi