Category "c"

Sum of numbers occurring in the multiplication table of 8. What's wrong with my code? Desirable output is 440, and I'm getting 33204

Sum of numbers occurring in the multiplication table of 8. What's wrong with my code? Desirable output is 440, and I'm getting 33204. #include <stdio.h>

Utilising Cython with Pyinstaller

I am trying to build a program in python using Cython and PyInstaller. Before starting, I built this test program. However, the two modules aren't working toget

Why is sleep in a child process blocking my program?

So I have this simple program that sleeps for 4 second if the value returned by fork is '0' meaning that the child process is executing, I've tried using sleep

linux socket lose data when a delay is added before read

I am learning linux socket programming, I expect that server can read data, even I add a delay but it just drops the buffer data, and receive the recent data, t

Rotating an image by x angle in c

I am rotating the image by x(45 degres) angle, But I am getting some black spots in the rotated image. How to avoid those black spots!! The logic I have used

Can I insert my code to my coded interface using Win32?

I have a C program and I am supposed to add an interface to it. Can I insert my code to my coded interface using Win32? Example: Here is my code to convert bina

Variable declaration inside curly braces

Why does the following code produce an error? I don't understand why the curly braces are making a difference. #include<stdio.h> int main(void) { {

How to add custom flag in CMake building

My main goal is to use a flag when building a project in command line. So I can add own flags like DEBUG or MY_FLAG. #ifdef DEBUG #define debug_print(format, ..

Why does webassembly use fetch before using module.malloc will cause runtimeerror?

When I open -s FETCH=1 and -s EXIT_RUNTIME=1 at the same time call emscripten_fetch after using Mudole._malloc, the following error will appear. Uncaught (in pr

Duplicate process without fork

In linux embedded system I can see in ps 2 processes of the same binary(pid1=X, pid2=Y) those processes don't have threads(/proc/X/task and /proc/Y/task don't e

Reversing a string on C language

In this program, the user is allowed to enter words of up to 20 letters, which are stored in another array and printed from the end. But there is error on my co

Enumerate all binary numbers of length n and weight at most k lexicographically

I'm looking for an algorithm which enumerates all binary numbers of a given length n lexicoraphically, with the constraint that every number is skipped, which h

C Problems with fscanf

Thanks for all the answers, after the corrections the code did not work for a stupid error ... I opened both files with the same file pointer "database" ... I'

May a compiler store function-scoped, non-static, const arrays in constant data and avoid per-call initialization?

In reading How are char arrays / strings stored in binary files (C/C++)?, I was thinking about the various ways in which the raw string involved, "Nancy", would

Interesting C macro, how is it able to take a field within a struct and return a reference to the struct?

I saw an interesting design for a doubly-linked-list inside the Pintos operating system and I don't quite understand how it was able to achieve this behavior. I

Can substitute PyCharm Professional for CLion - primarily for python

My favourite editor by far is PyCharm, mainly because I am most comfortable with Python. I am subscribed to the professional package, but I am interested in pi

Unable to stop a C program with infinite loop and printf within on macOS

#include <stdio.h> int main(void) { while(1) { printf("!"); } return 0; } This is my program. When I run it in the terminal, I can't

"C programming language" - Counting characters anomaly?

In The C Programming Language book by Ritchie & Kernighan, in §1.5.2 Counting Characters, two versions of the program are given: #include <stdio.h

addressSanitizer: heap-buffer-overflow on address

I am at the very beginning of learning C. I am trying to write a function to open a file, read a BUFFER_SIZE, store the content in an array, then track the cha

Query RTC and NTP time in Linux?

The way the Linux kernel handle time is somewhat complicated as it uses different source of time, and regularly resynchronize everything. There are command-line