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
3answers
107 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 ...
-2
votes
0answers
116 views

what's wrong with the code [closed]

This code is calculates power in logn time. power and power1 both are same function used to calculate i^j%MOD. I am getting negative value for 25^(1000000005)%1000000007. Power function returns ...
0
votes
1answer
88 views

Multi-threaded server

I have written a server/client program in which I am using 2 threads : One to recieve data continously and Other to send data as the user writes it on screen Problem: I have created the threads ...
8
votes
4answers
246 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 ...
0
votes
0answers
61 views

Which of these C “MAX” macros would be best? [migrated]

I see two possible implementations for a MAX macro in C. Which of these would be best? define MAX(X,Y) ((X) < (Y) ? : (Y) : (X)) define MAX(X,Y) 0.5*(X+Y+ABS(X-Y))
2
votes
2answers
272 views

How many `malloc` calls is too many? If any?

I'm implementing a system in C, implemented partially as a library. The library does most of the memory management itself, with the application layer just having to call *_destroy functions on the ...
-2
votes
0answers
76 views

Can I use scanf() function within printf() function giving a defined output? [migrated]

Can I use scanf() function within printf() function giving a defined output? If yes,then please explain me the Output for the simple code below: #include <stdio.h> #include <conio.h> int ...
7
votes
1answer
261 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 ...
-1
votes
0answers
23 views

How to add a new system call in OS/161? [migrated]

I am trying to add a new system call in my OS/161 code, but I am having trouble figuring out, where to add the prototypes. I believe your supposed to add it to the kernal space and user space, but I'm ...
-2
votes
0answers
72 views

Selection or Insertion sort [closed]

Is this code in function selection sort or insertion sort? Thanks. int* b = new int[n]; b[0] = a[0]; for(int i=1; i<n; i++) { int min = i; for(int j=0; j<n; j++) { ...
1
vote
4answers
301 views

Is using `continue`, `break` in non-`switch` loops and `?:` bad practice? [duplicate]

Back in college I've been told that using break; and continue; outside switch statements (e.g. to escape for or while loops) is wrong, bad practice and bad habits at the same time because it only ...
-1
votes
1answer
100 views

What features do you want in modern debuggers? [closed]

I am trying to build a better debugger for C/C++ and hopefully for Python and Javascript. I am not too happy single stepping through various lines of code to see what got executed and what did not. ...
5
votes
3answers
368 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 ...
0
votes
0answers
18 views

PHP extensions in C [migrated]

I am referring Sara Golemon "Extending and Embedding PHP". I am confused regarding the following snippet zval **fooval; if ...
-3
votes
1answer
84 views

Should i shift from Testing to Development? [closed]

i have 1.2 yrs of experience in Testing in big MNC company, I have good Programming knowledge in Java (Core,Servlets). I have completed ISTQB certification(Testing) and trying for HP QTP ...
1
vote
2answers
139 views

Time limit on user input

I am trying to put a time limit on the user input, so if they take longer than 2 seconds to put type in an input then the program will terminate. I was wondering if there is a simple way to do this in ...
7
votes
3answers
241 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 (...) */ ...
0
votes
4answers
303 views

Read K&R before learning low latency C++?

I have never really done a large amount of C programming but am in the middle of teaching myself low latency C++. Would it do more harm than good to read the K&R C programming book? I am a bit ...
2
votes
2answers
127 views

About ANSI C++ 2003 standard

I would like to ask for your help. I searched a lot on Internet, but I found mismatched informations. My questions: I tried to buy the "ISO/IEC 14882:2003(E) Programming Languages - C++" standard ...
1
vote
0answers
42 views

Makefiles and cross platform development [migrated]

I have been trying to figure out how to create a C program that can be compiled for all of the major operating systems. I have considered using makefiles so I would just have to change the target OS, ...
3
votes
0answers
110 views

malloc(sizeof(int)) vs malloc(sizeof(int *)) vs (int *)malloc(sizeof(int)) [migrated]

I acknowledge that all three of these have a different meaning. But, I don't understand on what particular instances would each of these apply. Can anyone share an example for each of these? Thank ...
4
votes
2answers
137 views

Allow threads (in c) to print messages without interfering with user input

I'm a writing a small webserver for personal use in c (not c++). I want to allow user input in the console like "shutdown server" or "restart server". In order to allow this kind of input the server ...
0
votes
1answer
199 views

I'm trying to create a visual representation of something, but I don't know what words to use, so I'll try to describe it

My project team is making a site that will use reddit style voting to track users' opinions on various issues, and use the data to create a "heat map". I say heat map in quotes because I'm not sure ...
-6
votes
3answers
203 views

Why is it not possible to break out of an if statement? [closed]

in C or C++: why can't we use break; to break an if statement? if( color == red ) { ... if( car == hyundai ) break; ... } But, why is it exactly, that it does no work ?
5
votes
4answers
321 views

main() function prototypes

As far as I know, main () function has the following prototypes: int main(); int main(int argc, char **argv); Now, C does not support overloading, then how are multiple prototypes of ...
2
votes
1answer
158 views

How much usage of “likely” and “unlikely” macros is too much?

The often known as likely and unlikely macros help the compiler know whether an if is usually going to be entered or skipped. Using it results in some (rather minor) performance improvements. I ...
26
votes
4answers
1k 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

Programming in a competitive environment as a motivator [closed]

I figured that a big motivator for me has always been competition. That's why I am looking for a platform where I can spend my free time coding on a project which will be compared with other projects ...
41
votes
4answers
15k views

Why do programming languages, especially C, use curly braces and not square ones? [closed]

The definition of "C-Style language" can practically be simplified down to "uses curly braces ({})." Why do we use that particular character (and why not something more reasonable, like [], which ...
-1
votes
1answer
81 views

Compile GPL-code into a JNI-capable shared library and use it in commercial software [closed]

I am developing an application for Android in JAVA which calls GPLed C-code via JNI. I have modified & capsulated a GPL-software under a JNI-interface and compile it as a shared library (.so) ...
1
vote
1answer
242 views

Using assembly to write to a file

I am working with a trading application (reading data from the exchange) which generates a bucket load of data on a per second basis. We have different "log-levels" but even the minimal log-level ...
-4
votes
1answer
110 views

GCC compiler for C and other languages [closed]

I have gone through many reference documents about how a GCC compiler optimizes program. But I am not sure how actually a programmer request GCC attempt to optimize a program. Plz help answering this ...
0
votes
3answers
200 views

C/C++ in applications that do not concern performance [closed]

C is the best language (or maybe the single language) suitable for operating systems, drivers, embedded systems etc. For more complex domains like computer graphics C++ is a better choice. But these ...
4
votes
1answer
311 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 ...
-4
votes
1answer
262 views

Learning advanced programming [closed]

I'm from India and it's not really a good place for learning and education. I'm an IT student, I've been studying various programming languages like Java, C, C++, VB etc. And its my final year in ...
6
votes
7answers
396 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
votes
1answer
99 views

Portability: Python's C/C++ libraries/extensions vs JRuby's Java libraries

I've had some discussion with colleagues who chose to go with JRuby along the following line of argumentation: JRuby can make use of anything that is available in Java, ergo such programs are more ...
0
votes
2answers
207 views

Need some advice and feedback on my code's design

I am looking for feedback on the design of my program. I have a shell script call function.sh that defines a lot of helper functions. My intent is to use those bash functions defined in functions.sh ...
32
votes
2answers
5k views

What is the purpose of NaN boxing?

Reading 21st Century C I arrived at chapter 6 at the section "Marking Exceptional Numeric Values with NaNs", where it explains the use of the bits in the mantissa to store some arbitrary bit patterns, ...
3
votes
2answers
92 views

Library design: provide a common header file or multiple headers

There are essentially two camps of library designers concerning the design of the final header file inclusion: Provide a single header file that includes every other header file that makes up the ...
1
vote
1answer
101 views

Implementing a sort of navigation system

So I am undertaking a project which does navigation sort of thing. So here is how the problem statement looks like. Say, given a map of a floor, with different rooms, now somehow, this information is ...
2
votes
1answer
307 views

Where did the T in wchar_t come from?

In many native types, a common suffix (and sometimes prefix) of t or _t is used to denote platform-independent types (such as wchar_t, int32_t, etc.) What was the logic behind the letter t as opposed ...
-3
votes
2answers
543 views

Why aren't there modern C IDEs? [closed]

Why weren't the features present in modern IDEs for Java & C# (Intellij IDEA, Visual Studio, eclipse) developed in (earlier) IDEs for C language? I mean I don't know any IDE which has modern ...
2
votes
4answers
595 views

Initializing char array with string

I don't remember how I got to the thread, but I was reading its replies and one of them states that you should never initialize a char[] with a string literal. My question: Is initializing a ...
1
vote
1answer
145 views

Parallel computing using xcode

I'm making mandelbrot fractals in C using Xcode and I want to use parallel computing but everything I've tried so far doesn't work. Such as This Question and other how to guides. Whats the easiest way ...
3
votes
2answers
499 views

Low Latency Unix/Linux

Most low latency/high frequency programming jobs (based on job specs) appear to be implemented on unix platforms. In a lot of the specs they make particular request for people with "low latency linux" ...
-1
votes
2answers
267 views

How to practice programming? [closed]

I've been a PHP developer for 5 years now. Before I started working in that field, I've been practicing at home. I've created my own CMS, so I could actually show some of my code to the potential ...
-2
votes
1answer
124 views

Should I go back to school to do computers if I have an MA degree? [closed]

I'm new to the forum so I will take this question down if it's not considered a good one. Thanks for your patience. Can I do computer programming at a major company with an MA in Political Science if ...
-2
votes
2answers
213 views

Difference in different C compilers [closed]

C comes in various forms like Turbo C, Borland C, Visual C++, C++, C#, C Borland Compiler, C++Builder, TurboC Simulator etc. I am confused in all of them. I think that difference in C, C++ and C# is ...
7
votes
5answers
805 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 ...

1 2 3 4 5 10