Category "c"

Does gcc use Intel's SSE 4.2 instructions for text processing if available?

I read here that Intel introduced SSE 4.2 instructions for accelerating string processing. Quote from the article: The SSE 4.2 instruction set, first implement

Netlink : Receiving data multiple times from kernel

I recently encounter a problem when I'm using netlink to transfer many data between userspace and kernelspace. For example, function in userspace releases a req

Print character array as hex in C

I have a 2D array called char **str (allocated by malloc). Lets say str[0] has the string "hello". How would I print that hex? I tried printf("%d\n", (unsigned

C/C++ unsigned integer overflow

i'm reading an article about integer security . here's the link: http://ptgmedia.pearsoncmg.com/images/0321335724/samplechapter/seacord_ch05.pdf In page 166,th

Why wasn't a specifier for `float` defined in `printf`?

It looks like it could have been, there are (at least in C99) length modifiers that can be applied to int: %hhd, %hd, %ld and %lld mean signed char, short, long

STM32F407 Register Level Clock Configuration Issue

I am working on an STM32F407 Discovery Board. But I didn't solve my clock configuration problem. I want to 168 MHz working frequency and I get help from CubeMX

Generate a random byte stream

I'm testing a network program that sends packet to a remote server using UDP/TCP, and for that, I want to generate some random byte streams. Here's the functio

maximum (and minimum) off_t

I could not find something like OFF_MAX that would tell me the maximum allowed value for off_t so I wonder if I could perhaps use that: #define OFF_MAX ~((off_

Fastest Implementation of the Natural Exponential Function Using SSE

I'm looking for an approximation of the natural exponential function operating on SSE element. Namely - __m128 exp( __m128 x ). I have an implementation whic

First Not Repeating Character Code

Here is the question: Write a solution that only iterates over the string once and uses O(1) additional memory, since this is what you would be asked to do duri

OSError: [WinError 193] %1 is not a valid Win32 application while reading custom DLL in python with CTypes

I am trying to write code that wraps a C library in python. I am planning on using CTypes to do it and I used visual studio to compile my DLL. I started with a

Creating a file using fopen()

I am just creating a basic file handling program. the code is this: #include <stdio.h> int main() { FILE *p; p=fopen("D:\\TENLINES.TXT","r"); if(p==0) {

Bluetooth pairing in C blueZ on Linux

I cannot find any reference on how to pair a bluetooth device on linux in a program written in C using the BlueZ Bluetooth libraries. I already managed to do a

Get a List of Child Processes from Parent Process in C and C++ (Cross-Platform, No Command Line)

How to get a list of child process ID's from a given parent process ID in a cross-platform manner in C and C++ without using command line? I provided an answer

Get the beginning of a string until a given char

I know that is a simple question but I couldn't find the answer. I have this string: "M1[r2][r3]" I want to get only the "M1", I'm looking for something li

How to calculate power in C

How do I calculate a power in C, and do you have to include anything? I have tried to include math.h, however it didn't work. What is de difference between a in

C program to print a sentence using threads & semaphores with infinite loop

i am currently trying to make a programm which will print the sentece "What a wonderful world" using three threads. The first thread should print "What A" , the

Is it possible to program your own kbhit() in C?

I took a class of programming at my university and I am working on some program. I want to know if it is possible to program my own kbhit() function. And if it

Number of trailing zeroes

I've written a function trailing_zeroes(int n) that returns the number of the trailing zeroes in the binary representation of a number. Example: 4 in binary is

C Standard Library for Win32/Win64 other than MSCRT

In unix/linux world, there are a couple of different C Standard Library implementations to choose from and link against, but although I spent some time searchin