Top "C" questions

C is a general-purpose programming language used for system programming (OS and embedded), libraries, games and cross-platform.

Time in milliseconds in C

Using the following code: #include<stdio.h> #include<time.h> int main() { clock_t start, stop; …

c time clock
How do you implement a circular buffer in C?

I have a need for a fixed-size (selectable at run-time when creating it, not compile-time) circular buffer which can hold …

c data-structures circular-buffer
Programmatically find the number of cores on a machine

Is there a way to determine how many cores a machine has from C/C++ in a platform-independent way? If …

c++ c multithreading multiplatform
How to read from stdin with fgets()?

I've written the following code to read a line from a terminal window, the problem is the code gets stuck …

c stdin fgets
Function to Calculate a CRC16 Checksum

I'm working on a library to provide simple reliable communication over an RS232 or RS485 connection. Part of this code …

c crc crc16
Creating a daemon in Linux

In Linux I want to add a daemon that cannot be stopped and which monitors filesystem changes. If any changes …

c linux daemon
Getting multiple values with scanf()

I am using scanf() to get a set of ints from the user. But I would like the user to …

c scanf
Easiest way to flip a boolean value?

I just want to flip a boolean based on what it already is. If it's true - make it false. …

c++ c boolean boolean-logic
How to convert string to float?

#include<stdio.h> #include<string.h> int main() { char s[100] ="4.0800" ; printf("float value : %4.8f\n" ,(float) …

c floating-point type-conversion atof strtod
Why isn't sizeof for a struct equal to the sum of sizeof of each member?

Why does the sizeof operator return a size larger for a structure than the total sizes of the structure's members?

c++ c struct sizeof c++-faq