Category "c"

Use semaphores for handling sockets in C

I have the following piece of code: SOCKET sock = open_socket(szListenHost, iListenPort); if (sock > 0) { SOCKET client; struct sockaddr_in peeraddr

/usr/bin/ld: final link failed: Illegal seek collect2: ld returned 1 exit status

I am running my program on linux server and it was compiling and running fine then i made another directory and tried to compile it in that directory and it w

Rewriting strlen() in C [closed]

if anyone has ever wanted to try and rewrite a string function in C, would this code work to replace the standard strlen() function? I have no

Determine file owner from a Windows kernel-mode driver

Using C in a Windows in a Kernel Mode Driver using KMDF, how do I determine the owner a of file? I searched high and low but could not find any hint. Only C++

Starting the debuggee failed: No executable specified, use `target exec'

Code: #include <stdio.h> #include <stdlib.h> #include <conio.h> // to generate numbers void gen_data(int b[], int n) { int i; for (i =

STM32 HAL Library RTC Alarm

I am having a problem about RTC Alarm configuration. First of all, I tried example code which is provided by Cube, and It works. But in my code, it doesn't work

STM32 HAL Library RTC Alarm

I am having a problem about RTC Alarm configuration. First of all, I tried example code which is provided by Cube, and It works. But in my code, it doesn't work

Program to reverse a number without using an array

This is the code that I used. It works perfectly, but I don't understand why it works. I just kept changing my original logic until I started using -1 in the co

How to install CDT to Eclipse Luna

I am trying to install the C/C++ development tools for Eclipse Luna. Taking reference from this page here, I navigated to Help> Install New Software> and

How to check if a struct is NULL in C or C++

i have the following structure typedef struct { char data1[10]; char data2[10]; AnotherStruct stData; }MyData; for some reason the imple

What is the difference between using a Makefile and CMake to compile the code?

I code in C/C++ and use a (GNU) Makefile to compile the code. I can do the same with CMake and get a Makefile. However, what is the difference between using a M

Dividing arbitrary large numbers stored in char arrays in C

A part of my home assignment requires dividing large integers that are so long I can only store them in character arrays. Both the divident and the divisor can

Closing libUV Handles Correctly

I'm trying to find out how to fix these memory leaks I'm getting while running this program with Valgrind. The leaks occur with the two allocations in nShell_cl

Which type of #include ("" or <>) when writing a library in C/C++

I am writing a library in C++. The library has multiple headers and cpp files and needs to be cross platform (Windows Visual Studio and Linux gcc). When built t

What is Biased Notation?

I have read: "Like an unsigned int, but offset by −(2^(n−1) − 1), where n is the number of bits in the numeral. Aside: Technically we co

Does gcc initialize long strings to `""` but not short ones?

Note: I know that reading an uninitialized string is undefined behaviour. This question is specifically about the GCC implementation. I am using GCC version 6.2

Which one is safer to use? " ==TRUE" or " != FALSE"

Is it better to compare a boolean type variable with: == FALSE and != FALSE; or == TRUE and != TRUE?

Implementing matrix operation using AVX in C

I'm trying to implement the following operation using AVX: for (i=0; i<N; i++) { for(j=0; j<N; j++) { for (k=0; k<K; k++) { d[i][j] += 2 *

XINU OS - Understanding roundmb function

I am studying XINU OS, and came across this simple one-line function. Is it possible to explain how this function is working and rounding x to nearest block siz

How to store a *signed* 24 bit int into another variable?

I need to encode a 24 bit integer into the end of 32 bit int. (the first byte contains other data, the other three are empty for use by the 24 bit int) I alr