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
63 views

At ping, why do we have to do array copying instead of passing on the on the source array that the client sent to us?

So I have been googling about this OpenSSL heart-bleed thing and somehow sees that it is caused by the heartbeat extension which requires client to ping the server to show its aliveness and it all ...
2
votes
3answers
44 views

Best and safest API for a function which fills a buffer with variable-length data

I have a function which receives a buffer and returns some data in the buffer. The data can be smaller than the buffer capacity. Which is the best and safest API for this? int fn(void *buffer, ...
4
votes
1answer
660 views

What's the current best practice for C multithreading?

I've been a Java (and PHP) developer for most of my life, but will need to use C for my next project. I remember some basic stuff we did back in school with fork, pthread, semaphores, etc. but I'm not ...
0
votes
0answers
10 views

Sempahores and Mutex Lock [migrated]

two scenarios, what is the difference. I cannot understand which to use. It seems that they basically do the same thing. pthread_lock(&mutex) critical section pthread_unlock(&mutex) vs ...
-2
votes
0answers
20 views

Standard DES encryption lib or package for C [on hold]

Is there a DES encryption lib or package for C that is similar to the Java DES package? thanks, John
3
votes
0answers
32 views

Advice for simple communication protocol (iPod and Arduino)

I connected iPod with Arduino using serial (UART) connection. Arduino sends 0-1023 number (so it's two bytes) as it's samples light sensor value. I'm asking about advice about simple and reliable ...
3
votes
2answers
97 views

How to manage memory in C interface for C++ implementation considering c++11?

I have a library implemented in C++ which has a C interface. This C interface is, for all intents and purposes, the only way to use this library. C++11 seems to discourage the use of raw pointers but ...
-2
votes
1answer
104 views

Advantages and Disadvantages of C CGI over PHP? [on hold]

I've developed a lot of websites with PHP but sometime after learning C programming I found out that it's possible to do the same thing using C CGI. But I still don't know if it will be worth ...
0
votes
2answers
217 views

Is there a better way to organize my module tests that avoids an explosion of new source files?

I've got a neat (so I thought) way of having each of my modules produce a unit-test executable if compiled with the -DTESTMODULE flag. This flag guards a main() function that can access all static ...
-4
votes
0answers
20 views

Saving an array to a binary file in C? [migrated]

Suppose I create an m by n matrix in the following manner: double (*myArr)[n] = malloc(m * sizeof(*myArr)); How would I then save that to a binary file? I've tried using fwrite, but I haven't ...
0
votes
2answers
47 views

Use one or multiple files for graphics properties?

I'm creating a 2D game in plain ANSI-C using SDL2. I'm planning to let users create their own graphics. So, to achieve this, I'll use an information file which will hold some data such as Width, ...
1
vote
4answers
1k views

Computation Program Not Running at 100% CPU Utilization

I have a program which has a GUI and performs some very heavy mathematical computations for a couple of minutes and then outputs a result. When I try to directly interface it through its DLL's, it ...
3
votes
2answers
193 views

Are (C) object files created with different compilers binary-compatible?

I understand that C++ compilers are not compatible with each other. However, I was unable to find anything on this topic for C in particular. I know that the C standard leaves a lot of room for ...
137
votes
15answers
64k views

When to use C over C++, and C++ over C?

I've been introduced to Computer Science for a little over a year now, and from my experience it seems that C and C++ are both considered to be "ultrafast" languages, whereas others such as Python and ...
0
votes
1answer
56 views

Looking for a certain datatype if it exists

I'm looking for the kind of a certain datatypes. The main idea of this datatype is to describe a productionline containing several steps. Each step should be represented as a "vertex" containing an ...
-2
votes
0answers
40 views

Cricket Score Board in C [closed]

I was Coding for my final project submission and there is error that the individual player's score doesn't add up according to the input, have a look and please correct me if I'm in the wrong section. ...
0
votes
5answers
80 views

What conclusion to be drawn from no difference in generated assembly from 2 rather different programs?

I might not have had a counterexample when I got the reply "A pointer is just an address, what's the difficulty?" but I didn't really buy such a simple explanation and at assembly code it's not ...
-1
votes
0answers
97 views

Is there a difference between writing/passing value with or without float “f” suffix? [migrated]

I believe I should type less if it's possible. Any unnecessary keystroke takes a bit a time. In the context of objective-C, my question is: Can I type this [UIColor colorWithRed:0 green:0 blue:0 ...
5
votes
3answers
2k views

Make use of design patterns in C? [closed]

Design patterns are useful for object oriented languages. But how can a non-object-oriented language such as C make of use them?
0
votes
0answers
74 views

Adding Very Large Array's in C. Is there a better way to do this? [migrated]

I am writing a stochastic simulation for a yule process. It basically works likes this if you start with a certain number of bins each containing a random number of balls you add another ball to an ...
5
votes
4answers
1k views

Learning C for C++ programmers [closed]

That's right, I learned to program in C++, and of course know the common set of features of both languages, so I can program in C. But I'd really like to read tutorials or books that teach you C, and ...
0
votes
0answers
48 views

What concept is being exhibited in this macro wrapping? [migrated]

A bunch of code just got handed over to me and I got baffled by macros in the header. I could not understand what they are for: #define WRAPPER_MACRO(symbol) symbol #define ANOTHER_SYMBOL ...
-1
votes
0answers
32 views

Basic C programming [migrated]

I'm trying to write a program which given a certain number of input will output the product of the listed input (only accounting inputs of 0-9 and ignoring other). For example: input:345 would result ...
3
votes
5answers
2k views

Is it possible to write an operating system in C?

A while back I saw a comment on a Stack Overflow question that surprised me: No one can write an operating system in C. It is not possible. What one can do is write an operating system in a ...
2
votes
4answers
454 views

Why do we use to talk about addresses and memory of variable in C?

Why do we use to talk about addresses and memory of variable in C, where in other languages (like in Java, .Net etc) we do not talk about variable address and memory in a program, we will directly use ...
0
votes
0answers
3 views

Creating multiple child processes in C for one parent [migrated]

Everyone! So I've been working on code for my OS class, and in my project, I have to create a new child process for each file on the command line, and pipe information from the child to the parent. ...
0
votes
1answer
63 views

Algorithm for base-conversion in C?

I put in this code which does what it's supposed to do, but perhaps there is a better or more general approach? I'm converting a 4-digit base 10 number e.g. "11" to base 16 e.g. "17" (which gets ...
0
votes
0answers
2 views

putting file-scope variables inside a struct? What is the benefit [migrated]

As a C developer I always used to place file-scope variables as their own variable. static char myChar; static char *myCharPtr; Now I've started people seeing to be placing these variables inside a ...
0
votes
1answer
77 views

How can I handle this string concatenation in C in a reusable way

I've been writing a small C application that operates on files, and I've found that I have been copy+pasting this code around my functions: char fullpath[PATH_MAX]; fullpath[0] = '\0'; ...
8
votes
10answers
3k views

When can I say I know how to program in C? [closed]

Let's see. I've seen in several places, including Advice for Computer Science College Students, by Joel Spolsky, that a graduated Computer Science student must know C. How do I know if I know C or ...
2
votes
2answers
168 views

Representing a deck of cards in C (not C++)

So far my best ideas have been as fallows A) Represent a "card" in one structure and have a "deck" in another a deck being an array of 52 cards and a card being 2 chars one for and rank one for suit. ...
1
vote
4answers
214 views

How do you call one program from another?

What I'm wondering is how running programs communicate with each other, and if someone could post some sample code for how to do this, so I can try it out myself, just for educational purposes. For ...
34
votes
3answers
23k views

How to become a Kernel/Systems/Device driver programmer?

I currently work in a professional capacity as a software engineer working with the Android OS. We work at integrating our platform as a native daemon among other facets of the project. I primarily ...
1
vote
0answers
65 views

What is the underlying mechanism behind va_list and where is it defined?

http://www.cplusplus.com/reference/cstdarg/va_list/ According to the above link, va_list is an argument or parameter used in some macros - va_start, va_arg, va_end. These macros are present in the ...
0
votes
1answer
152 views

What is this programming style? “Monoid-ic”?

In a moderately old blog post, Conal Elliot makes an interesting (if less than serious) argument that C is a purely functional language, by drawing a parallel between the combination of the C ...
1
vote
0answers
89 views

How to extract the active code path from a complex algorithm

I have been puzzled lately by an intruiging idea. I wonder if there is a (known) method to extract the executed source code from a large complex algorithm. I will try to elaborate this question: ...
7
votes
7answers
2k 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
5answers
228 views

How to alter the code at runtime in an interpreter?

While reading the difference between Compiler and interpreter , I found the following differences fromt he internet. Advantages of using compiler: Since compiler converts the program to native code ...
1
vote
1answer
82 views

Global variable vs. local-static variable for storing state

I am writing an application for my graduation coursework, in C, using GTK+ UI library. Sometimes I ask for user input, which I need to save for later use. The doubt comes on how to store this data. I ...
15
votes
2answers
1k views

What happened to Concurrent C?

I recently checked out a fantastic book from my college library. It is a bit old at 1989, but the language it describes sounds rather nice. And even while I may not be using it soon, I wanted to ...
7
votes
5answers
6k views

What should and what shouldn't be in a header file? [closed]

What things should absolutely never be included in a header file? If for example I'm working with a documented industry standard format that has a lot of constants, is it a good practice to define ...
13
votes
5answers
18k views

How to write a very basic compiler

Advanced compilers like gcc compile codes into machine readable files according to the language in which the code has been written (e.g. C, C++, etc). In fact, they interpret the meaning of each codes ...
0
votes
2answers
169 views

Shared source file between two parts of project [closed]

I have the following sort of directory structure: part1 build src part2 build src Now I have a header file that I would like to include in both parts of these projects, it will ...
3
votes
2answers
219 views

Speed difference between VM-based and compiled code [closed]

Not so long ago I was told by a senior academic that, these days, VM-based code could run nearly as fast as compiled code, but my own experience is that compiled code runs several orders of time ...
1
vote
2answers
202 views

Creation of an Assembler [closed]

I've always been interested in how programming languages are created, so for the past 8 months I've been researching, practicing and more about the creation of compilers. I've been able to quite ...
11
votes
10answers
2k views

Greenspun's Tenth Rule, does every large project include a Lisp interpreter? [closed]

Greenspun's tenth rule (actually the only rule) states that: Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of ...
1
vote
0answers
90 views

Problem with Vi editor using PuTTy [closed]

For my computer science class for intro to c/c++ we are using the PuTTy client to work with Vi. During one of my assignments I was in the other room and apparently my cat jumped up on my laptop and ...
27
votes
3answers
63k views

Android development using C and C++

I am a C, C++ developer. I am interested in mobile development. I want to know how can I develop Android apps using C and C++, I have read that they are providing a kit for C, C++ developers but it ...
4
votes
3answers
294 views

How to teach pointers to beginners in C? [closed]

I'll hold a little presentation about C-Pointers in a small group of people with beginners programming skills, with no CS background. Just people who would like to learn something about coding and ...
1
vote
3answers
185 views

Requiring a specific order of compilaiton

When designing a compiled programming language, is it a bad idea to require a specific order of compilation of separate units, according to their dependencies? To illustrate what I mean, consider C. ...