Category "c"

Writing an image to a socket in C

I made a server that can serve html to a browser, but for some reason it wont send images. Every time I send an image over the socket, the browser receives some

How can a compile a c codefile as a efi app?

I have a c code file and I would like to compile it as an efi application. How can this be done using linux and windows cli tools (i.e. without creating a visua

vector addition in OPENCL /C

I hope you are well, I have a problem with an opencl program, I execute the following program of the vector addition #define CL_USE_DEPRECATED_OPENCL_1_2APIS #i

Explanation of C++ FAQ's unsafe macro?

According to the C++ FAQ, macros are evil: [9.5] Why should I use inline functions instead of plain old #define macros? Because #define macros are ev

Explanation of C++ FAQ's unsafe macro?

According to the C++ FAQ, macros are evil: [9.5] Why should I use inline functions instead of plain old #define macros? Because #define macros are ev

Bubble sorting using function and pointers

I have this function code to bubble sort an array using pointers. However, I do not understand the second for loop (the inner one): Why did they do p < a + n

How can I fetch the length of a character array and put it in an array?

I'm working with my STM32 but since I'm new to c/c++ (coming from c#) i find string operations a bit difficult. Until now I'm sending serial like this: strcpy

How do I manipulate the contents of a stat() struct?

I have a stat struct, and I'm looking for a way to get data out of it to be manipulated. The program will successfully run and print the desired st_mtime value,

WebKitGtk doesn't load local files

I've tried loading a local html file using webkit_web_view_load_uri() with a file:// URL. However, the webview would display a blank page. To circumvent this, I

The condition within the while statement

How can I write a condition that fulfills the same condition as inside the while clause without using a <stdbool.h> void show_path(int a[][5]) { int i =

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