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

learn more… | top users | synonyms

21
votes
4answers
719 views

C++ Linkage Languages other than C?

The C++ language allows intermixing of both C++ and C in one source file. For example, extern "C" { struct bar { /* ... */ } } Does C++ or has it ever supported any other "linkage languages" ...
0
votes
2answers
417 views

What is the exact syntax of inline?

CASE 1 (Definition and declaration in same source file) Suppose both my prototype and definition of global function is in .cpp file. Where should I write inline keyword to make compiler know? In ...
3
votes
5answers
518 views

Is it bad to place “include directive” within main function?

It is always said that the include directives should be placed at the beginning of a script. The main reason is to make the functions available throughout the script. Regardless of this fact, is it ...
2
votes
1answer
340 views

Maintaining code-style conventions for large projects [closed]

For a while I've been maintaining an ad-hoc script to check code style against our project's guidelines. I'm aware of AStyle/Uncrustify and have used them, but they are best for once-off code-style ...
1
vote
2answers
2k views

When using int's as boolean values, is it in poor form to use 0's and 1' directly?

Is it better to do this #define INT_TRUE 1 #define INT_FALSE 0 int someFunctionalityIsEnabled = INT_TRUE; or this? int someFunctionalityIsEnabled = 1; It can be safely assumed that false will ...
3
votes
2answers
535 views

C Equivalent of Perl Unpack & Pack

I have some perl code that uses pack and unpack to transform the data in a way that I don't understand. $unpacked_data = pack('b*', join('', unpack('(b7)*', $packed_data))) Where $packed_data = a ...
3
votes
4answers
1k views

What do other languages offer when it comes to infrastructure technology that could indicate its advantage over C in the future?

I have been going through interview questions and I saw one which made me stop and think for a while. It starts with a quote and asks about your interpretation and whether you agree or not. "For ...
0
votes
2answers
580 views

Better design for a generic doubly linked list around which I plan to make different wrappers?

I am currently writing a C code for a doubly linked list(dll) around which I want to write wrapers for implementing stack, queues etc. instead of writing separate codes for all of them. I'll be ...
4
votes
3answers
478 views

Rationale behind C library functions never setting errno to zero

The C standard mandates that no C standard library functions shall set errno to zero. Why exactly is this? I could understand it being useful for calling several functions, and only checking errno ...
0
votes
1answer
650 views

Having trouble understanding recursion [duplicate]

I have just started learning about recursion but I'm having a hard time understanding it. Please would you recommend any links or books that explain recursion in detail.
0
votes
4answers
998 views

How should I go about developing some basic C/C++ knowledge so that I can grok the concepts written in some Classic software programming books? [closed]

I know Java and JavaScript pretty well. I have never really worked on C/C++. But at this stage of my career I feel that the fact that I do not have adequate knowledge on C/C++ syntax(especially ...
3
votes
1answer
360 views

Pure C Vector Implementation

I am implementing a vector in C. I am doing this for the fun of programming, for the fun of learning, and for the use of the data structure in later projects. This is not homework. My question is ...
6
votes
4answers
1k views

When is the register keyword actually useful in C?

I am confused about the use of register keyword in C. It is generally told that its use isn't needed like in this question on stackoverflow. Is this keyword totally redundant in C due to modern ...
17
votes
7answers
2k views

Does modular programming affect computation time?

Everyone says that I should make my code modular, but isn't it less efficient if I use more method calls rather than fewer, but larger, methods? What is the difference in Java, C, or C++ for that ...
15
votes
4answers
256 views

how to determine minimum requirements of a software [duplicate]

Some software (commonly the commercial ones) producers provide minimum requirements, some examples: Skype, Diablo III, Ubuntu-Server and OpenOffice. I wonder how those minimum requirements are ...
4
votes
2answers
499 views

Learning YACC nowadays, does it make sense? [closed]

I have a huge project that is using YACC and I would need to fix a bug in it. I might ask someone else who wrote that to fix it but I'm interested in how compilers work. Does it make sense to learn ...
16
votes
4answers
932 views

Is it necessary to follow the standard , take the C standard for that matter?

May be this question is a duplicate and I am a dumb to ask it here, but I searched a bit and none of the titles suggested to answer my question exactly . There are some very experienced folks on SO ...
1
vote
2answers
304 views

Multiple Data Types for Single Variable in C

I am trying to implement basic cons, car and cdr of SCHEME in C. I have made a simple program that allows me to cons two integers as shown in the main program. However, I want my program to be able to ...
12
votes
4answers
790 views

When and for what purposes should the const keyword be used in C for variables?

While getting my code reviewed here the issue of using the const keyword came up. I understand that it is used for implementing read-only behaviour on variables. I am confused about what are the ...
4
votes
1answer
3k views

How do I learn modern C? [closed]

I started programming about 20 years ago with the first edition of the book C for Dummies. It was a great introduction to code and I am now a professional software developer. However, these days I ...
6
votes
4answers
1k 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 ...
1
vote
1answer
431 views

register variable in C and C++

I know the concept of register variable and it's use cases but there are few questions in my mind based on what I have tried. I cannot access the address of a register variable in C though I can do ...
1
vote
4answers
2k views

Help with learning the C++ Qt Framework [closed]

I've been a longtime PHP web developer. But now I've reached the limits and web doesn't fascinate me anymore. I am interested in learning cross-platform development. I have learned Java for almost a ...
3
votes
3answers
348 views

Blank lines in C

I'm working through K&R and I notice that their code is extremely tightly spaced. I haven't developed C since at University, but professionally most source from other languages I've worked in has ...
5
votes
4answers
639 views

How to familiarize myself with Python

I'm a Python beginner. I started programming with Python 1.5 months back. I downloaded the Python docs and read some parts of the tutorial. I have been programming on codechef.com and solving ...
2
votes
1answer
373 views

Are C or C++ The Only Viable Languages for a GC

Background I have just finished writing a compiler for a functional language compiling to the JVM as a learning project. However, since I'm just doing this to learn, I thought it might be interesting ...
4
votes
1answer
328 views

s expression representation for c

Experimenting with various lisps lately (clojure especially) i have wondered if there are any s expression based representations of (subsets) of c, so you could use lisp/closure to write macros and ...
2
votes
2answers
513 views

Concept of bit fields

Whenever I read a code like this: struct node { int x : 2; int p : 4; }n; with bit fields involved, I get really confused, as to how they are represented in memory, what ...
5
votes
6answers
5k views

Naming conventions used for variables and functions in C

While coding a large project in C I came upon a problem. If I keep on writing more code then there will be a time when it will be difficult for me to organize the code. I mean that the naming for ...
11
votes
4answers
1k views

Is there industry demand for developers who have no GUI experience?

Is there still demand for developers who crate software without GUI's in the industry? Are jobs still in demand? I only ask because I write a lot of software for myself in C. I mainly use FreeBSD ...
0
votes
1answer
706 views

Why nginx's http parser doesnt use regular expressions?

I see the http parser written by Igor Sysoev for nginx does not use regular expressions https://github.com/joyent/http-parser What could be the main reason for such design decision? I guess I could ...
6
votes
3answers
444 views

C project avoiding naming conflicts

I'm struggling to find pragmatic real-world advice on function naming conventions for a medium sized C library project. My library project is separated into a few modules and submodules with their own ...
4
votes
3answers
370 views

What is “short-circuiting” in C?

I have heard of the term "short-circuiting" being used in C. What does this mean and in what scenario would it be used?
16
votes
3answers
2k views

How to solve the problem of nested comments

It appears in not just one language that comments can't be nested. Do you have a good solution for this problem? One workaround in C/C++ and Java is to only use the single-line comment but it becomes ...
2
votes
1answer
144 views

.c FIle Dedicated to Data

Is it completely unheard of to have a .c file dedicated to just data? In my case, I'd be using it for global variables that are shared across two other .c files. Here's specifically how I'm using it. ...
6
votes
4answers
958 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. ...
1
vote
1answer
158 views

Design for migrating to Multitenant architecture

We are in a process of redesigning our product code in such a way so as to support multitenancy. Currently the implementation is such that one product deployment caters to only one customer. Thus ...
4
votes
6answers
2k views

sizeof style: sizeof(type) or sizeof variable?

I've seen two styles of using sizeof for memory-related operations (such as in memset or malloc): sizeof(type), and sizeof variable or sizeof(variable) Which one would you prefer, or would you use ...
7
votes
5answers
629 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 ...
6
votes
3answers
735 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 ...
0
votes
0answers
238 views

How does a dynamic library's references to a static variable get translated once in the running app?

If a dynamic library exports the address to a global variable defined within the library, how are accesses to that variable translated during dynamic linking so that a running application can interact ...
2
votes
1answer
125 views

Evaluation order of the expressions

The C Programming Language by K & R states that C, like most languages, does not specify the order in which operands of an operator are evaluated. (The exceptions are &&,||,?: and ','). ...
-1
votes
2answers
104 views

I'm trying to figure out which functions from one C library are being used by C project. Does anyone have a simple solution? [closed]

To be specific, I want to know which function/types in libpri and being used in the Asterisk project. I'm not traditionally a C programmer, but I know some basic stuff because I took a class in ...
0
votes
2answers
404 views

Giving a double type for sqrt library function in C

The C Programming Language by Ritchie says that: The library routine sqrt expects a double type and will produce nonsense if inadvertently handled something else. So if n is an integer, we can use ...
1
vote
1answer
122 views

Implementation defined behaviour changing const type in c

The C standard states that if an attempt is made to change a const type,the result is implementation defined.This gives error on my system,but what does it depend on(compiler,os)? What are the ...
1
vote
3answers
286 views

Violation of the C definition?

The C standard states that any character in the machine's standard printing set will never be negative.But the following code: char c=1234; printf("%d\t%c",c,c); gives a negative output and prints ...
2
votes
1answer
404 views

Source code of jar.exe - is it available

This may seem an odd question, but I want to create an executable which runs under Windows written in C++. The program needs to be able to update a jar file even if Java is not installed on the ...
2
votes
4answers
532 views

Is Objective C a reasonable way to learn C?

I want to learn C but I tend to learn best when I have a project to work on. I've never done iPhone development, so I'm hoping to kill two birds with one stone. Will learning objective c also teach me ...
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; ...
0
votes
3answers
6k views

Char and unsigned char [closed]

Where is unsigned char used in C ( please tell about some real-world examples )? Why would we need both char and unsigned char? Char ranges from -127 to 128 ( 8-bit integer ) Unsigned Char ranges ...