C is a general-purpose computer programming language used for operating systems, games and other high performance work.

learn more… | top users | synonyms

3
votes
1answer
4k views

Non Blocking Sockets vs Blocking sockets - UDP - C&linux

When to use blocking sockets over non blocking sockets on UDP? Question 1:What's is recommended for the following scenario ? Multiple clients send data over multiple UDP sockets, i.e. say client1 ...
2
votes
1answer
313 views

A simple C library filling the gaps in standard (C, POSIX) libraries?

I'm looking for a C function library, which would contain a collection of simple and plain utility functions "missing" from C or POSIX standards. I found this earlier question, but answers there list ...
0
votes
3answers
92 views

How to manage intermediate outputs efficiently?

I am implementing a C preprocessor in C... I have the three functions: trigraph replacing function Line splicing function comment removing function However these functions work separately on ...
1
vote
1answer
233 views

Handling timeout in network application

How can I handle timeouts in a network application. I'm implementing a provisioning system on a Linux server, the code is huge so I'm going to put the algorithm, it works as like this Read ...
0
votes
2answers
1k views

Should I use extern global variables or static global variables with “get” and “set” functions in C [duplicate]

I am working on one of my first projects in C (microcontroller code) which is split up into multiple C files. I noticed some inconsistency in my coding where I had some variables declared as extern ...
5
votes
4answers
1k views

To integrate git versions as build numbers or not?

A colleague and I have been taking turns debating/discussing the issues/merits of integrating a version derived from the current git repository into our code whenever it builds. We think the merits ...
0
votes
1answer
397 views

Multi-threaded server

I have written a server/client program in which I am using 2 threads : One to recieve data continously and Other to send data as the user writes it on screen Problem: I have created the threads ...
8
votes
4answers
364 views

What situations are appropriate for C# to C interop?

Given that C# has the unsafe keyword, are there situations in which it would still be beneficial to interoperate with C libraries? I could see the need for very fast number crunching, graphical ...
2
votes
2answers
792 views

How many `malloc` calls is too many? If any?

I'm implementing a system in C, implemented partially as a library. The library does most of the memory management itself, with the application layer just having to call *_destroy functions on the ...
7
votes
1answer
649 views

How are operating systems compiled and booted the very first time?

I'm interested in how operating systems work. I've been reading some articles about Linux and seem to understand how it all generally comes together, but I feel like there's a chicken and egg dilemma ...
1
vote
4answers
2k views

Is using `continue`, `break` in non-`switch` loops and `?:` bad practice? [duplicate]

Back in college I've been told that using break; and continue; outside switch statements (e.g. to escape for or while loops) is wrong, bad practice and bad habits at the same time because it only ...
6
votes
3answers
5k views

A good C Variable Length Array example

This question got rather a freezing reception at SO, so I decided to delete it there and try here instead. If you think it does not fit here either, please at least leave a comment on suggestion how ...
-3
votes
1answer
281 views

Should i shift from Testing to Development? [closed]

i have 1.2 yrs of experience in Testing in big MNC company, I have good Programming knowledge in Java (Core,Servlets). I have completed ISTQB certification(Testing) and trying for HP QTP ...
1
vote
2answers
539 views

Time limit on user input

I am trying to put a time limit on the user input, so if they take longer than 2 seconds to put type in an input then the program will terminate. I was wondering if there is a simple way to do this in ...
7
votes
3answers
293 views

Is there a way to use gcc as a library?

Anyone knows a solution that works something like this: #include <stdio.h> #include <gcc.h> /* This .h is what I'm looking for. */ int main (void) { /* variables declaration (...) */ ...
0
votes
4answers
674 views

Read K&R before learning low latency C++?

I have never really done a large amount of C programming but am in the middle of teaching myself low latency C++. Would it do more harm than good to read the K&R C programming book? I am a bit ...
2
votes
2answers
456 views

About ANSI C++ 2003 standard

I would like to ask for your help. I searched a lot on Internet, but I found mismatched informations. My questions: I tried to buy the "ISO/IEC 14882:2003(E) Programming Languages - C++" standard ...
5
votes
2answers
429 views

Allow threads (in c) to print messages without interfering with user input

I'm a writing a small webserver for personal use in c (not c++). I want to allow user input in the console like "shutdown server" or "restart server". In order to allow this kind of input the server ...
0
votes
1answer
288 views

I'm trying to create a visual representation of something, but I don't know what words to use, so I'll try to describe it

My project team is making a site that will use reddit style voting to track users' opinions on various issues, and use the data to create a "heat map". I say heat map in quotes because I'm not sure ...
5
votes
4answers
1k views

main() function prototypes

As far as I know, main () function has the following prototypes: int main(); int main(int argc, char **argv); Now, C does not support overloading, then how are multiple prototypes of ...
5
votes
1answer
803 views

How much usage of “likely” and “unlikely” macros is too much?

The often known as likely and unlikely macros help the compiler know whether an if is usually going to be entered or skipped. Using it results in some (rather minor) performance improvements. I ...
51
votes
5answers
30k views

When do you use float and when do you use double

Frequently in my programming experience I need to make a decision whether I should use float or double for my real numbers. Sometimes I go for float, sometimes I go for double, but really this feels ...
68
votes
3answers
22k views

Why do programming languages, especially C, use curly braces and not square ones?

The definition of "C-Style language" can practically be simplified down to "uses curly braces ({})." Why do we use that particular character (and why not something more reasonable, like [], which ...
-1
votes
1answer
206 views

Compile GPL-code into a JNI-capable shared library and use it in commercial software [closed]

I am developing an application for Android in JAVA which calls GPLed C-code via JNI. I have modified & capsulated a GPL-software under a JNI-interface and compile it as a shared library (.so) ...
1
vote
1answer
466 views

Using assembly to write to a file

I am working with a trading application (reading data from the exchange) which generates a bucket load of data on a per second basis. We have different "log-levels" but even the minimal log-level ...
0
votes
3answers
279 views

C/C++ in applications that do not concern performance [closed]

C is the best language (or maybe the single language) suitable for operating systems, drivers, embedded systems etc. For more complex domains like computer graphics C++ is a better choice. But these ...
8
votes
1answer
9k views

programming PID loops in C

I'm an electrical engineer that was kind of thrust into the digital world and learning as I go. I'm programming a TI processor to do a PID (proportional-integral-derivative) loop, illustrated by this ...
7
votes
7answers
3k views

When should pointers be checked for NULL in C?

Summary: Should a function in C always check to make sure it is not dereferencing a NULL pointer? If not when is it appropriate to skip these checks? Details: I've been reading some books about ...
1
vote
1answer
289 views

Portability: Python's C/C++ libraries/extensions vs JRuby's Java libraries

I've had some discussion with colleagues who chose to go with JRuby along the following line of argumentation: JRuby can make use of anything that is available in Java, ergo such programs are more ...
0
votes
2answers
262 views

Need some advice and feedback on my code's design

I am looking for feedback on the design of my program. I have a shell script call function.sh that defines a lot of helper functions. My intent is to use those bash functions defined in functions.sh ...
35
votes
2answers
6k views

What is the purpose of NaN boxing?

Reading 21st Century C I arrived at chapter 6 at the section "Marking Exceptional Numeric Values with NaNs", where it explains the use of the bits in the mantissa to store some arbitrary bit patterns, ...
3
votes
2answers
1k views

Library design: provide a common header file or multiple headers

There are essentially two camps of library designers concerning the design of the final header file inclusion: Provide a single header file that includes every other header file that makes up the ...
1
vote
1answer
158 views

Implementing a sort of navigation system

So I am undertaking a project which does navigation sort of thing. So here is how the problem statement looks like. Say, given a map of a floor, with different rooms, now somehow, this information is ...
2
votes
1answer
411 views

Where did the T in wchar_t come from?

In many native types, a common suffix (and sometimes prefix) of t or _t is used to denote platform-independent types (such as wchar_t, int32_t, etc.) What was the logic behind the letter t as opposed ...
-4
votes
2answers
859 views

Why aren't there modern C IDEs? [closed]

Why weren't the features present in modern IDEs for Java & C# (Intellij IDEA, Visual Studio, eclipse) developed in (earlier) IDEs for C language? I mean I don't know any IDE which has modern ...
4
votes
4answers
38k views

Initializing char array with string

I don't remember how I got to the thread, but I was reading its replies and one of them states that you should never initialize a char[] with a string literal. My question: Is initializing a ...
1
vote
1answer
534 views

Parallel computing using xcode

I'm making mandelbrot fractals in C using Xcode and I want to use parallel computing but everything I've tried so far doesn't work. Such as This Question and other how to guides. Whats the easiest way ...
4
votes
2answers
5k views

Low Latency Unix/Linux

Most low latency/high frequency programming jobs (based on job specs) appear to be implemented on unix platforms. In a lot of the specs they make particular request for people with "low latency linux" ...
0
votes
2answers
501 views

How to practice programming? [closed]

I've been a PHP developer for 5 years now. Before I started working in that field, I've been practicing at home. I've created my own CMS, so I could actually show some of my code to the potential ...
7
votes
5answers
995 views

Is code duplication a necessary evil in C?

I'm rather new to C, and I'm wondering if code duplication is a necessary evil when it comes to writing common data structures and C in general? I could try to write a generic implementation for a ...
22
votes
2answers
1k views

What does it mean to expose a C++ code publicly as a C API and what are the advantages of doing it?

I often hear people say that C++ programmers should expose their library's/product's public API as a C API. What does that mean and what are the advantages of that?
-1
votes
1answer
2k views

Streaming data from a microcontroller to a server? [closed]

Edit *We have a heart monitor hooked up to to an msp430 with a roving networks wifi module. I would like to connect send some type of a datastream to a webserver so that someone could watch it ...
3
votes
6answers
6k views

What is a 'Null Terminated String' ?

I have just started reading C++, and I came across a term "Null Terminated String", I read about it but couldn't understand what it actually stands for. I also want to know what is the difference ...
6
votes
1answer
280 views

Difference between language virtual machine and emulating vm?

I'm having a hard time understanding the difference between an emulation virtual machine and a language vm. I started with the research and implementation of an emulation virtual machine. Primarily ...
4
votes
2answers
295 views

What is the lifecycle for loading a Linux Desktop Environment?

I'm looking into delving into a bit of custom OS work (and yes I understand that doing any development at the DE level or lower on an OS is extremely complex and not a light thing to undertake, ...
0
votes
3answers
799 views

How to efficiently store IP addresses? [closed]

Background I have a requirement where I need to remove a few nodes in a network based upon a command given by the user. To keep the nodes from transmitting or receiving data I thought of changing its ...
11
votes
8answers
1k views

Does low latency code sometimes have to be “ugly”?

(This is mainly aimed at those who have specific knowledge of low latency systems, to avoid people just answering with unsubstantiated opinions). Do you feel there is a trade-off between writing ...
3
votes
3answers
289 views

is Microsoft LC random generator patented?

I need a very simple pseudo random generator (no any specific quality requirements) and I found Microsoft's variant of LCG algorithm used for rand() C runtime library function fit my needs (gcc's one ...
4
votes
1answer
233 views

unseen/unknown function definition in linux source

Can any one please explain this piece of code I found in the linux kernel source. I see a lots of code like this in linux and minix kernel but dont seem to find what it does (even if C compilers ...
2
votes
8answers
787 views

tips, guidelines, points to remember for rendering professional code? [closed]

I'm talking about giving clients professional looking code. The whole nine yards, everything you hardcore professional highly experienced programmers here probably do when coding freelance or for the ...