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
0answers
16 views

a free light and fast DICOM C/C++ tool [on hold]

I am looking for a free (free for be integrated in commercial product) licensed, light weight and fast DICOM tool, so that I can read the information (pixel intensity, header....) from DICOM file. ...
1
vote
3answers
67 views

Will C compiler attach the whole object code of the header file?

When you compile a C source code does the compiler convert the whole header file to object code or just the functions of the header file you use? Like for example, in the header file #include ...
-1
votes
0answers
7 views

escaping a complete packet read in apache module

According to this site: http://pedrowa.weba.sk/docs/ApiDoc/apidoc_ap_get_client_block.html This function: ap_get_client_block(request_rec *r, char *buffer, int bufsiz); Reads a chunk of POST ...
1
vote
2answers
111 views

In C, what is an unconditional jump?

I have to fill out some documentation regarding a C project i worked on. One topic is whether I used "unconditional jumps". As far as I know, a "break" statement counts as a jump. And I have a few of ...
-1
votes
0answers
41 views

Handling race conditions in C using the most efficient method

I created my own linux apache module in C but after installing it on the server, I found out that in a day, the server receives at least 1,000 requests of which 4 return a segmentation fault message ...
2
votes
2answers
72 views

Returning multiple values from a c function using pointers; style of parameter list

What is good programming style for writing C-language functions and function calls to functions which return pointers? For example, if I have a function my_function which return two integers through ...
111
votes
6answers
21k views

Is every language written in C?

Sometimes while programming in different languages (C/C++, C#), this thought comes to my mind: Is each and every language written in the C programming language? Is the C language the mother/father ...
0
votes
0answers
4 views

Help with enum in C [migrated]

I am trying to understand some C code in a legacy database. There are constructions there of the form: enum {a=0,b,c,d}; What does this achieve ? In the manuals, I only see constructions of the ...
0
votes
0answers
37 views

web requesting - time competition - javascript? [on hold]

first of all, I would like you to excuse my english and description of the problem. I am not english native speaking, so I am trying my best.... Before you say, that is am abusing some server- I need ...
-2
votes
1answer
31 views

Service that compile & test your C code on different platforms [on hold]

I was wondering if there was some service that would compile & run automated tests on different platforms like multiple versions of Windows, Linux, Mac etc. and give you a report about any ...
2
votes
2answers
63 views

Should I use multiple state machines for a layered protocol?

When implementing a layered communications protocol are layers commonly implemented as state machines? I have an implementation of PMBus I am currently working on for an embedded device. I have a ...
-2
votes
0answers
20 views

Strange behaviour of visual studio 2008 with escape sequence [migrated]

Regarding C programming language, the descriptions of escape sequence does not resolve the output of following line in visual studio 2008. char * str = "??/abc"; printf( "%s", str ); it prints only ...
1
vote
0answers
66 views

How to use an enumeration type, when the values are not known at first?

We have a project, that consists of a cluster of C source code, a C library and a C++ library. The C++ library is dependent only upon the C library, or at least that is what I am trying to achieve. ...
0
votes
1answer
52 views

forking but not exiting

It is normal for the child in a fork() to call exec() or _exit(). Are there any realistic scenarios where the child might return from the function that called fork() instead? void foo() { pid_t ...
11
votes
2answers
557 views

Java has the JVM, what does C have?

I know that C has a compiler but what determines execution performance? For example in an if else block, what if the code just had all ifs instead of if elses, what determines that all the ifs will ...
-1
votes
3answers
110 views

is it possible to make a gui in c without an external library [closed]

I was wondering if it is possible to make a gui application in c without the use of an external library (like gtk+ or wxWidgets). And if it not possible without the use of an external library, how ...
-1
votes
0answers
95 views

Convert an 8 bit data to 3 bit data [migrated]

PROGRAMMING LANGUAGE: C I've a 8 bit data with only 3 bit used, for example: 0110 0001 Where 0 indicate unused bit that are always set to 0 and 1 indicate bits that change. I want to convert this ...
0
votes
2answers
102 views

Trouble understanding simple recursion in c [duplicate]

My function: int num(int x) { if(x>0) num(x-1); else return 0; printf("%d",x); } This function takes a input x and prints the numbers from 1 upto x.I can't seem to ...
11
votes
5answers
68k views

Is initializing a char[] with a string literal bad practice?

I was reading a thread titled "strlen vs sizeof" on CodeGuru, and one of the replies states that "it's anyways [sic] bad practice to initialie [sic] a char array with a string literal." Is this true, ...
0
votes
6answers
1k views

Why languages that compile to C/C++ generate unreadable, cryptic code? [closed]

I'm willing to compile certain language to C or C++ for some speedups. My idea was, though, to generate readable code and use structures such std::vector and similar wherever I can, expecting CLANG to ...
-3
votes
2answers
133 views

Can a high level language be faster than native C? [closed]

Hand-crafted C is almost unbeatable. If an experienced C developer knows what he is doing, he will be able to write C code much faster than higher level code. But can a medium/big programme written in ...
53
votes
6answers
10k views

Why are there so few C compilers? [closed]

C is one of the most widely-used languages in the world. It accounts for a huge proportion of existing code and continues to be used for a vast amount of new code. It's beloved by its users, it's so ...
25
votes
11answers
7k views

typedefs and #defines

We all have definitely used typedefs and #defines one time or the other. Today while working with them, I started pondering on a thing. Consider the below 2 situations to use int data type with ...
0
votes
5answers
488 views

Is a makefile really needed

I have been programming in c/c++ for a while now, and I have never once used a makefile. I know that it is supposed to be useful when you are dealing with a large project, but I have always been able ...
9
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. ...
-1
votes
0answers
51 views

Understanding the program that reads a set of text lines and prints the longest in K&R's book [migrated]

I'm reading K&R's book, section 1.9. The program for printing the longest line, from a given set of lines, is given as #include <stdio.h> #define MAXLINE 1000 /* maximum ...
1
vote
0answers
14 views

How to use mcheck? [migrated]

I am trying to understand how heap consistency checking works in GNU C Library. I Refered http://www.gnu.org/software/libc/manual/html_node/Heap-Consistency-Checking.html#Heap-Consistency-Checking ...
3
votes
2answers
623 views

How do you usually compile C/C++ source code ? (Large code bases) [closed]

It's been quite some times since I began learning C and C++ but I've been very limited only to the Windows platform and the Visual Studio environment. Recently, I wanted to look into some open source ...
-1
votes
1answer
71 views

Understanding the solution of exercise 1.16 of K&R as given in the “The C Answer book”

The exercise 1.16 in K&R's book asks, Revise the main routine of the longest-line program so it will correctly print the length of arbitrary long input lines, and as much as possible of ...
0
votes
1answer
170 views

Understanding the solution of Exercise 1.12 of K&R's book as given in the book “The C Answer Book”

I am reading the solution of "The C Answer Book". I think that the solution of Ex. 1.12 can be shortened. The Exercise is as, Write a program that prints its input one word per line. The ...
11
votes
2answers
4k views

Why does C use the asterisk for pointers?

I'm just now learning about C. I find it odd that the creators chose the asterisk (*) as the symbol for pointers rather than a symbol that actually looks like a pointer (->). Considering how ...
-1
votes
1answer
72 views

How static functions are better than Class Methods in Objective-C [closed]

I was going to through this post by Mattt Thompson in which he mentions that Static functions are nicer than shoe-horned class methods I just don't see any flaw with Class methods in ...
0
votes
2answers
102 views

Organizing C++ Components [closed]

In my current company we've brought the discussion about how to organize most of our different C++ components considering the following requirements: There might be interdependencies between ...
1
vote
2answers
460 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 ...
0
votes
3answers
45 views

Data inter-exchange with C

I'm developing a system in which a C coded TCP server is listening for new connections from clients, on connection parse the data & store into database. I'm familiar with JSON, and would like to ...
-3
votes
0answers
38 views

Proper Decimal Problem? [migrated]

#include <stdio.h> int main (){ float M=2E30, G=6.67E-11, m=6E24, r=1.5E11; float F= (G*M*m)/(r*r); printf("F is %f",F); return 0; } I am trying to print the value of F with ...
2
votes
1answer
166 views

An embedded C developer wishing to interface some code with a web page

Okay, so as the title says, I'm an embedded C/C++ developer. Right now, I'm working on a project that involves a client/server C application. The server side of the application is running on ...
2
votes
1answer
104 views

Functions returning strings, good style?

In my C programs I often need a way to make a string representation of my ADTs. Even if I don't need to print the string to screen in any way, it is neat to have such method for debugging. So this ...
2
votes
2answers
175 views

Place variables frequently used by the same function on the heap?

Say that I have the following situation: void myFunc() { int x; //Do something with x } "x" is placed on the stack which is no doubt fast. Now, "myFunc" is called very frequently, lets say ...
75
votes
7answers
60k 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 ...
0
votes
1answer
114 views

C-library - newbie guide

I have been asked to provide a C-library of my code (which I have written in a high-level language). I will hire a programmer to implement my code in C. I would like a short introduction to what a ...
4
votes
3answers
3k views

C Flexible Arrays: When did they become part of the standard?

I learned to program in C many years ago, and used C steadily for about 10 years. These days, I occasionally have to look at C code, because our Informix 4GL RDS customized runners also contain C ...
0
votes
0answers
7 views

Initializing complex structure, GCC warns: initialized field with side-effects overwritten [migrated]

I'm coding a backgammon position evaluation system and I'm trying to use designated initalizers, compound literals and a variadic macro to create a keyword argument function like described here , and ...
3
votes
1answer
106 views

Transpose a matrix without a buffering one

How is it possible to transpose a MxN matrix without using a "buffering" matrix? In the latter case it's easy and quite the "classic" approach... Given a matrix[M][N], I would like to put it into a ...
1
vote
5answers
982 views

Is Operator Overloading supported in C

When I read about the LCC (Windows) compiler, I found out it has the implementation for operator overloading. However, after a bit of Googling, I've confirmed that operator overloading isn't ...
3
votes
1answer
116 views

Structure of stack of a function call

I've been reading Aleph One's paper on Smashing the Stack for Fun and Profit. I wrote down example1.c from his paper, modified it a bit to see what the stack looks like on my system. I'm running ...
3
votes
1answer
93 views

Proper way of handling EINTR in libraries

What is the recommended etiquette when it comes to EINTR in libraries? I'm currently writing a function that does some file system tasks with the POSIX API, but a lot of the calls I use can ...
-1
votes
1answer
70 views

How to create user defined conditional statements in c? [closed]

I have two stacks s1 and s2 with numbers stored in them. I have a function(say comp) which compares the numerical values of s1 and s2. I want to know if it is possible to modify the function so that ...
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 ...
0
votes
3answers
139 views

Understanding the concept of “arguments” and “parameters” in C language as explained in K&R The C Programming Language

In the third last paragraph at page number 26 of the ebook "The C Programming Language" the author(s) say, "We will generally use parameter for a variable named in the parenthesized list in a ...