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
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 ...
8
votes
5answers
7k views

Why can you have the method definition inside the header file in C++ when in C you cannot?

In C, you cannot have the function definition/implementation inside the header file. However, in C++ you can have full method implementation inside the header file. Why is the behaviour different?
8
votes
6answers
5k views

practical way to learn C? [closed]

I want to dig into C and normally when I want to learn a new language I think of a simple/attainable project goal that has some practical purpose (make use of an api, automate a task, etc...) I'm ...
8
votes
4answers
3k views

Is there any difference between return n and exit(n) in C?

Is there any difference between return n (in the main function) and exit(n) in C? Is it defined by C or POSIX standards or it depends on OS or compiler?
8
votes
7answers
8k views

C/C++ Best indentation length? [closed]

I was reading a Vim tutorial ( http://www.oualline.com/vim-cook.html#drawing ), and came across this: This is very useful if you use a 4 space indentation for your C or C++ programs. (Studies at ...
8
votes
5answers
650 views

Are C static libraries frowned upon? [closed]

There are 2 arguments for having shared libraries: It helps reduce disk space. When a shared library is updated, all the binaries depending on it get the update. There is mainly one drawback for ...
8
votes
3answers
918 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 ...
8
votes
5answers
2k 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 ...
8
votes
4answers
1k views

Undefined behaviour in Java

I was reading this question on SO which discusses some common undefined behavior in C++, and I wondered: does Java also have undefined behaviour? If that is the case, then what are some common causes ...
8
votes
5answers
709 views

Is it better to have C developers learn Flash, than hire Flash guys?

Last year, my department developed web based gaming, and needed Flash. It was difficult to manage. The Flash guys didn't fit in regardless of skill or popularity in the office. Maybe it's prejudice ...
8
votes
4answers
540 views

What features did c get from c++?

What features were added to C that were originally in C++? When where they added and for what reason(what where the pro/con arguments)? How do they differ in C as compared to C++? Did the features ...
8
votes
4answers
1k views

Where does Objective-C come from? C++ or C?

I am very confused about this programming language, Objective-C, which I heard is used to develop iOS applications. I know that it uses the principles of OOP. Would it be easier to learn if I already ...
8
votes
6answers
1k views

Should my team use some common well-regarded coding standard as a basis for its own?

The R&D team I'm in has decided to adopt a coding standard. We have only recently formed, and have too little code and common coding time of our own to base our standards/conventions document on ...
8
votes
4answers
3k views

Is it important to know C/C++ for Android development?

Is it possible to use only Java (without C++ /NDK) for building good, fast, beautiful Android apps (including 3D development)? When I look for Android developer position requirements (vacancies), I ...
8
votes
4answers
393 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 ...
8
votes
3answers
8k 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 ...
8
votes
2answers
390 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 ...
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
2k 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
7answers
2k views

C language portability

How exactly is portability of a language like C is determined? I've learned that compilers are ISA specific. If this is true, how is C portable? Or is it that just the source code written in C is ...
7
votes
5answers
1k 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
4k 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
1answer
2k 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?
7
votes
5answers
705 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
6answers
13k 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. ...
7
votes
4answers
3k 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 ...
7
votes
2answers
2k views

Why the ugly keywords in C11?

I am currently reading a draft of the C11 specification. The new introduced keywords: _Bool, _Alignof, _Atomic all feel like custom extensions, instead of standard reserved keywords like struct, ...
7
votes
5answers
625 views

Undefined behavior, in principle

Whether in C or C++, I think that this illegal program, whose behavior according to the C or C++ standard is undefined, is interesting: #include <stdio.h> int foo() { int a; const int ...
7
votes
4answers
2k 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 ...
7
votes
4answers
811 views

When does it make sense to compile my own language to C code first?

When designing an own programming language, when does it make sense to write a converter that takes the source code and converts it to C or C++ code so that I can use an existing compiler like gcc to ...
7
votes
1answer
958 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
187 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
4answers
303 views

Omitting “destructors” in C is taking YAGNI too far?

I'm working on a medium embedded application in C using OO-like techniques. My "classes" are .h/.c modules using data structs and function pointers structs to emulate encapsulation, polymorphism, and ...
7
votes
3answers
300 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
3answers
3k 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
1k 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
225 views

Autoreleasing objects in Reference Counting Systems

I'm experimenting a bit in C and I'm trying to implement my own Reference Counting System. I've mainly worked with Objective-C in the past but AFAIK autoreleasing objects is something that is unique ...
7
votes
2answers
1k 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
614 views

Macro vs. Static functions in Header

for a lot of quick tasks where one could employ a function f(x,y), in plain C, macros are used. I would like to ask specifically about these cases, that are solvable by a function call (i.e. macros ...
7
votes
1answer
916 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
1answer
246 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 ...
7
votes
1answer
251 views

Do any notable C extensions include integer types whose behavior is independent of machine word size

An interesting characteristic of C compared with some other languages is that many of its data types are based upon the word size of the target architecture, rather than being specified in absolute ...
7
votes
4answers
279 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
6answers
4k 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
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
3answers
638 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
2answers
980 views

Why is C still in the category of High Level Language? [closed]

Many of the textbooks on the C programming language tell that C is a high-level programming language, but many of the tutors online say that C is also a middle-level programming language. Why is it ...
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
909 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 ...