Top "C" questions

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

How to wrap printf() into a function or macro?

This sounds a little like an interview question,but is actually a practical problem. I am working with an embedded …

c logging c99 word-wrap
Clear screen in C and C++ on UNIX-based system?

I want to know: how to clean screen on an UNIX-based system? I searched on the Internet, but I've just …

c unix screen cls
Why was the switch statement designed to need a break?

Given a simple switch statement switch (int) { case 1 : { printf("1\n"); break; } case 2 : { printf("2\n"); } case 3 : { printf("3\n"); } } The absence of …

c language-design
How to make bit wise XOR in C

I'm trying to get into C programming, and I'm having trouble writing a bitwise XOR function with only ~ and & …

c bit xor
How can I terminate an infinite loop in Turbo C?

I get stuck in an infinite loop. How can I terminate this loop? I tried to use/press Cntrlc but …

c infinite-loop turbo-c
Providing/passing argument to signal handler

Can I provide/pass any arguments to signal handler? /* Signal handling */ struct sigaction act; act.sa_handler = signal_handler; /* some …

c signals signal-handling
How can I create a Makefile for C projects with SRC, OBJ, and BIN subdirectories?

A few months ago, I came up with the following generic Makefile for school assignments: # ------------------------------------------------ # Generic Makefile # # Author: yanick.…

c makefile
Visual C++ equivalent of GCC's __attribute__ ((__packed__))

For some compilers, there is a packing specifier for structs, for example :: RealView ARM compiler has "__packed" Gnu C Compiler …

c++ c visual-c++ gcc data-structures
Signal handling with multiple threads in Linux

In Linux, what happens when a program (that possibly has multiple threads) receives a signal, like SIGTERM or SIGHUP? Which …

c linux multithreading signals ipc
Reversing a linkedlist recursively in c

The following code works fine when head is sent as a parameter to it. As I am new to C, …

c recursion linked-list singly-linked-list