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

learn more… | top users | synonyms

8
votes
1answer
8k 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 ...
8
votes
2answers
379 views

Why error codes are negated?

Very often I see in C code negation of returned error codes, e.g. return -EINVAL instead of return EINVAL. Why used negation?
8
votes
3answers
2k views

How much C/C++ knowledge is needed for Objective-C/iPhone development?

First, a little background. I'm a .Net developer (C#) and have over 5 years experience in both web development and desktop applications. I've been wanting to look into iPhone development for some time ...
8
votes
3answers
377 views

what counts as “experience” with a particular language?

I'm a CS student currently in the process of looking for summer internships, specifically because I want to develop apps for Android and/or iOS. When looking over requirements for various ...
7
votes
9answers
1k views

How to explain pointers to a Java/VB programmer [closed]

I am writing a game and my friend has offered to help me as it is a RPG and will take a long time to do the "scripting" bit of the game. The problem is IMO he's not that good a programmer :( (add ...
7
votes
9answers
1k views

Is it any good to use binary arithmetic in a C++ code like “C style”?

I like the fact that the C language lets you use binary arithmetic in an explicit way in your code, sometimes the use of the binary arithmetic can also give you a little edge in terms of performance; ...
7
votes
5answers
3k views

Why do schools (or most schools) teach Java as the intro language? [duplicate]

Possible Duplicate: Why do we study Java at university? This is a question I've wondered a lot as a young developer that just graduated from college. Why do schools teach Java in-depth vs ...
7
votes
5answers
977 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 ...
7
votes
5answers
600 views

I believe I have mixed C and C++ code when I shouldn't have; Is this a problem and how to rectify?

Background/Scenario I started writing a CLI application purely in C (my first proper C or C++ program that wasn't "Hello World" or a variation thereof). Around midway through I was working with ...
7
votes
7answers
1k views

Learning the nuances of a language (C++)

So I'm a recent college graduate, and I really enjoy working in C++; I worked with it a lot in school, and would like to pursue a career writing in C or C++. The problem I'm having is that I'm trying ...
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 ...
7
votes
1answer
868 views

“Read” a file without using a file pointer

I was asked this question in an interview. I'm somehow supposed to "read" a file into my C program as input without using a file pointer (including "f" functions, e.g. fgets, fscanf etc.). I'm also ...
7
votes
1answer
177 views

What are the absolute, minimum requirement for containing SE Asian charsets for an embedded system project?

I work for a company that has begun integrating embedded computer systems into our products that we manufacture. We have a pretty wide range of products and they are distributed across the globe. ...
7
votes
3answers
290 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 (...) */ ...
7
votes
5answers
8k 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 ...
7
votes
3answers
2k views

Career in Embedded Systems For CS Major

I'm entering my last few semesters of a CS degree and looking to start a career in Embedded Systems. From talking to a lot of people it seems like I might have been better off with a Computer ...
7
votes
4answers
884 views

Semi-intelligent “diff” utility

Part of the QA steps required for a project I am tangentially involved with require the person who is responsible to integrate new version of source file to first calculate how many lines have been ...
7
votes
2answers
994 views

Questions about linking libraries in C

I am learning C (still very much a beginner) on Linux using the GCC compiler. I have noticed that some libraries, such as the library used with the math.h header, need to be linked in manually when ...
7
votes
1answer
596 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 ...
7
votes
4answers
273 views

What is an effective way to convert a shared memory-mapped system to another data access model?

I have a code base that is designed around shared memory. Each process that needs to access the memory maps it into its own address space. The data structures in the shared memory are directly ...
6
votes
10answers
1k views

How do these hotshot developers keep changing their technology base? [closed]

Yesterday I was watching a lynda.com iphone development video and this developer started telling about how he has worked on 17 different languages from the days of mainframes in assembly/Cobol to now ...
6
votes
6answers
3k views

Why should we use low level languages if a high level one like python can do almost everything? [closed]

I know python is not suitable for things like microcontrolers, make drivers etc, but besides that, you can do everything using python, companys get stuck with speed optimizations for real hard time ...
6
votes
4answers
613 views

Is doing two things on one line always a bad practice?

int *itPins = pins; for(int i = 0; i < count; i++) { ConfigureGpifPinAsGpioOutput(itPins); itPins++; } I have the impression that doing two things in one line is bad practice. This is why ...
6
votes
11answers
3k views

Learning C, C++ and C# [duplicate]

I'm sure you guys are tired of this question but after wading through hours of similar posts and questions I've really not made any progress to my specific concerns. I was hoping you guys could shed ...
6
votes
9answers
894 views

Review quality of code [duplicate]

I have been asked to quality review two code bases. I've never done anything like that, and need advice on how to perform it and report it. Background There are two providers of code, one in VB and ...
6
votes
1answer
1k views

Is C a regular language?

Are C or C++ regular languages? If not, under which category do we place the programming languages like C/C++, perl, Python?
6
votes
9answers
2k views

What is exactly the meaning of “portability”?

I know very well that java is a portable language..and it is the byte-code that makes it portable.. However I've studied also that C is a portable language. "The programs written in C are portable ...
6
votes
4answers
879 views

I am incompetent; how can I fix it? [duplicate]

I program in C and I believe I know the language well. I understand all the concepts and my problems never come from misuse of the language. I have problems because I always forget or oversee things. ...
6
votes
5answers
1k views

What's so bad about pointers in C++?

To continue the discussion in Why are pointers not recommended when coding with C++ Suppose you have a class that encapsulates objects which need some initialisation to be valid - like a network ...
6
votes
4answers
561 views

Should functions of a C library always expect a string's length?

I'm currently working on a library written in C. Many functions of this library expect a string as char* or const char* in their arguments. I started out with those functions always expecting the ...
6
votes
6answers
7k views

What does it mean to do a “null check” in C or C++?

I have been learning C++ and I am having a hard time understanding null. In particular, the tutorials I have read mention doing a "null check", but I am not sure what that means or why it's necessary. ...
6
votes
6answers
3k views

Is there a language that transcompiles to C with a better syntax? [closed]

CoffeeScript is a language with a very clean Ruby-like syntax that transcompiles to JavaScript. Does the same thing exists with C? Then writing more readable and as fast as original C programs would ...
6
votes
1answer
2k views

Is this a valid example of a dangling pointer?

The book "Data Structures in C" (Horowitz and Sahni) suggests that in the following code the pointer pf is behaving as a dangling reference: float f,*pf; pf=(float*) malloc(sizeof(float)); *pf=2.6; ...
6
votes
4answers
2k views

GO instead of C/C++ with cgo

Is it possible to replace C and C++ with Go + cgo and interface frameworks such as Qt or DirectX with Go? Any potential pitfalls I should be aware of? UPDATE: I see that my question was not precise ...
6
votes
8answers
415 views

What is the possible disadvantage of putting declarations in inner blocks, instead of at beginning of function?

At the place where I work, there are explicit guidelines for placement of declarations of variables. According to that, it is required to put them at the global level and / or at the beginning of ...
6
votes
3answers
656 views

Reason for placing function type and method name on different lines in C

I just started at a company and one of the style comments at my first code review was that the return type and method name should be on different lines. For example, this void foo() { } should be ...
6
votes
4answers
828 views

What are some standard design methods to add GUI to a command line app? [closed]

I have an embedded linux c application that runs with a simple CLI. I am now tasked with creating a GUI that accomplishes the same functionality as the command line program. I am not an accomplished ...
6
votes
2answers
663 views

Why use typedefs for structs?

in C (ANSI, C99, etc.), structs live in their own namespace. A struct for a linked list might look something like this: struct my_buffer_type { struct my_buffer_type * next; struct ...
6
votes
3answers
620 views

Why is scanf called scanf? (Same for printf.)

I am just curious why in the C programming language the function to read formatted input was called "scanf" as opposed to "readf". I assume it is derived from an earlier language, so in that case why ...
6
votes
3answers
987 views

What are the common misuses of “enum” in C?

I have seen C code where people used enum heavily. But all it does is confuse others. In many places plain integers can do the same thing with less ambiguity. What are the common misuses of enum?
6
votes
2answers
964 views

The need for Explicit Type Conversion in C#

Consider the following code: DerivedClass drbObj = (DerivedClass)obj; Here obj is of type Object and this is reasonable since Object is the base type of every Class in C#. Here, since the type of ...
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 ...
6
votes
2answers
426 views

What's the reason for C standard to consider const-ness recursively?

The C99 standard says in 6.5.16:2: An assignment operator shall have a modifiable lvalue as its left operand. and in 6.3.2.1:1: A modifiable lvalue is an lvalue that does not have array ...
6
votes
2answers
388 views

Are there any reliable solutions for annotations/reflection/code-metadata in C?

Not all languages support java-like annotations or C#-like attributes or code metadata in general, however that doesn't mean it is not possible to have in languages that don't have this. An example ...
6
votes
2answers
736 views

Need help eliminating dead code paths and variables from C source code

I have a legacy C code on my hands, and I am given the task to filter dead/unused symbols and paths from it. Over the time there were many insertions and deletions, causing lots of unused symbols. I ...
6
votes
2answers
787 views

designing large scale applications in a low level language

I have been learning C for a while but still get confused about designing large programs within C (a large application such as the Linux kernel). Moving from Java where you have classes it's ...
6
votes
1answer
266 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 ...
6
votes
3answers
236 views

Approach for developing software that will need to be ported to multiple mobile platforms in the future

I am currently doing the preliminary design for a new product my company will be pushing out soon. We will start on Android, but then we will need to quickly develop the IPhone, IPad.... and then the ...
6
votes
1answer
212 views

Suggested method for extracting a standalone C library from an existing R package?

My group has been developing an R package to simulate plant growth (see GitHub repository). The R package uses .Call to interface with C. We have decided that it would be worthwhile to create a ...
6
votes
0answers
167 views

Why is it so difficult to fix buffer overflows? [duplicate]

Possible Duplicate: Why is it so difficult to make C less prone to buffer overflows? I'm doing a course in college, where one of the labs is to perform buffer overflow exploits on code they ...